{"id":28509114,"url":"https://github.com/atomicobject/motion-objection","last_synced_at":"2025-07-22T19:33:57.562Z","repository":{"id":9849065,"uuid":"11842628","full_name":"atomicobject/motion-objection","owner":"atomicobject","description":"Wrapping Objection in RubyMotion.","archived":false,"fork":false,"pushed_at":"2015-01-14T16:02:17.000Z","size":1108,"stargazers_count":25,"open_issues_count":0,"forks_count":0,"subscribers_count":27,"default_branch":"develop","last_synced_at":"2025-07-13T18:35:47.480Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.objection-framework.org","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomicobject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-02T12:18:49.000Z","updated_at":"2023-05-03T10:27:05.000Z","dependencies_parsed_at":"2022-09-09T23:02:13.855Z","dependency_job_id":null,"html_url":"https://github.com/atomicobject/motion-objection","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/atomicobject/motion-objection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fmotion-objection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fmotion-objection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fmotion-objection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fmotion-objection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicobject","download_url":"https://codeload.github.com/atomicobject/motion-objection/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicobject%2Fmotion-objection/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266561336,"owners_count":23948627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-08T22:07:28.518Z","updated_at":"2025-07-22T19:33:57.533Z","avatar_url":"https://github.com/atomicobject.png","language":"Ruby","readme":"motion-objection\n================\n\nMotion-objection wraps the Objective-C dependency injection library [Objection](https://github.com/atomicobject/objection) in Ruby so that it can be used in [RubyMotion](http://www.rubymotion.com/). It has all of the power (and speed) of Objection and the declarative affordances that the Ruby language provides.\n\n[![Build Status](https://travis-ci.org/atomicobject/motion-objection.png)](https://travis-ci.org/atomicobject/motion-objection)\n[![Gem Version](https://badge.fury.io/rb/motion-objection.png)](http://badge.fury.io/rb/motion-objection)\n[![Code Climate](https://codeclimate.com/github/atomicobject/motion-objection.png)](https://codeclimate.com/github/atomicobject/motion-objection)\n\n## Installation\n\n\n```bash\ngem install motion-objection\n```\n\n## Basic Usage\n\nA class can declare requires component objects by mixing in \u003ccode\u003eObjection::Compose\u003c/code\u003e and calling the \u003ccode\u003e.compose_with\u003c/code\u003e method \n\n```ruby\nclass Car\n  include Objection::Compose\n  compose_with :engine, :brakes\nend\n```\n\nWhere \u003ccode\u003e:engine\u003c/code\u003e and \u003ccode\u003e:brakes\u003c/code\u003e are assumed to be the \u003ccode\u003eEngine\u003c/code\u003e and \u003ccode\u003eBrakes\u003c/code\u003e classes. Classes that are namespaced can be declared as well by separating the namespaces using the \u003ccode\u003e/\u003c/code\u003e character.\n\n```ruby\nclass Engine\n  include Objection::Compose\n  compose_with 'engine/crank_shaft', 'engine/rod'\n\n  class CrankShaft\n  end \n\n  class Rod\n  end\nend\n```\n\nSometimes you may need to declare the component object _and_ the class that is associated with it.\n\n```ruby\nclass Brakes\ncompose_with factory: JSObjectFactory\nend\n```\n\n## Singletons\n\nSingletons can be declared by calling the \u003ccode\u003e.singleton\u003c/code\u003e method in the class body. Singletons should really only be necessary if they contain _shared state_. Otherwise it behooves you to avoid singletons in order to reduce the memory footprint of an application.\n\n```ruby\nclass Holder\ninclude Objection::Compose\nsingleton\nend\n```\n\n## Awaking from Objection\n\nSince Objection utilizes _setter_ based injection the initializer does not guarentee that all the object's dependencies have been satisfied.\n\nThe `awoken` class method can be given a block which will be invoked once the object has been fully instantiated.\n\n```ruby\nclass Ship\n  awoken do\n    # Bootstrap listeners\n  end\n  \n  awoken do\n    # Setup other stuff\n  end\nend\n```\n\n## Default Initializers\n\nObjection uses [Key-Value Coding](http://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/KeyValueCoding/Articles/KeyValueCoding.html) to compose an instance with its dependencies -- it does not use initializer injection.\n\nBy default Objection initializes an object using the \u003ccode\u003einit\u003c/code\u003e initializer. A custom initializer can be declared using the \u003ccode\u003e.initializer\u003c/code\u003e method.\n\n```ruby\nclass ViewController \u003c UIViewController\n  include Objection::Compose\n  initializer \"initWithNibName:bundle:\", \"Home\"\n\n  attr_reader :name\n\n  def initWithNibName(name, bundle: bundle)\n    self.init\n    self.tap do\n      @name = name\n    end\n  end\nend\n```\n\n## Modules\n\nModules contribution configuration information to the Injector. Typically, this includes bindings for dependencies that the Injector cannot provide. For example, \u003ccode\u003eUIApplication.sharedApplication\u003c/code\u003e or the main application window.\n\n```ruby\nclass AppModule \u003c JSObjectionModule\n  def initialize(window, application: application)\n    @window = window\n    @application = application\n  end\n  \n  def configure\n    bind @window, toClass: UIWindow\n    bind @application, toClass: UIApplication\n  end\nend\n```\n\nThere are a number of other configuration methods a module [provides](https://github.com/atomicobject/objection#modules).\n\n## Bootstraping an Application\n\nTypically an application is bootstrapped in the application delegate where an injector is created and set as the default injector via \u003ccode\u003e.default_injector=\u003c/code\u003e.\n\n```ruby\nclass AppDelegate\n  def application(application, didFinishLaunchingWithOptions:launchOptions)\n    initialize_objection\n    Objection.default_injector[ApplicationBootstrapper].bootstrap!\n    true\n  end\n  \n    def initialize_objection\n    @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)\n    injector = Objection.injector(BankersDashboardModule.new(@window, UIApplication.sharedApplication))\n    Objection.default_injector = injector\n  end\nend\n\nclass ApplicationBootstrapper\n  def bootstrap!\n    # Bootstrap\n  end\nend\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicobject%2Fmotion-objection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicobject%2Fmotion-objection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicobject%2Fmotion-objection/lists"}