Class: Metro::ModelFactory
- Inherits:
-
Object
- Object
- Metro::ModelFactory
- Defined in:
- lib/metro/models/model_factory.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #class_for_actor(model_name) ⇒ Object
- #create ⇒ Object
-
#initialize(name, options) ⇒ ModelFactory
constructor
A new instance of ModelFactory.
- #load_from_previous_scene? ⇒ Boolean
- #model_name ⇒ Object
- #options ⇒ Object
Constructor Details
#initialize(name, options) ⇒ ModelFactory
Returns a new instance of ModelFactory.
6 7 8 9 |
# File 'lib/metro/models/model_factory.rb', line 6 def initialize(name,) @name = name.to_s.downcase @options = .symbolize_keys end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/metro/models/model_factory.rb', line 4 def name @name end |
Instance Method Details
#class_for_actor(model_name) ⇒ Object
28 29 30 |
# File 'lib/metro/models/model_factory.rb', line 28 def class_for_actor(model_name) Models.find(model_name) end |
#create ⇒ Object
11 12 13 14 |
# File 'lib/metro/models/model_factory.rb', line 11 def create actor_class = class_for_actor(model_name) actor_class.new end |
#load_from_previous_scene? ⇒ Boolean
16 17 18 |
# File 'lib/metro/models/model_factory.rb', line 16 def load_from_previous_scene? @options[:from] == :previous_scene end |
#model_name ⇒ Object
24 25 26 |
# File 'lib/metro/models/model_factory.rb', line 24 def model_name [:model] || name end |
#options ⇒ Object
20 21 22 |
# File 'lib/metro/models/model_factory.rb', line 20 def @options.except(:from) end |