Class: Metro::Model::ModelProperty
- Defined in:
- lib/metro/models/properties/model_property.rb
Overview
A model property maintains a reference to another model. This property allows for an existing model to be more easily composed with other models.
The model is stored as a hash which describes the model.
Constant Summary
Constants included from Units
Instance Attribute Summary
Attributes inherited from Property
Instance Method Summary collapse
-
#create_model ⇒ Metro::Model
Return a model created by the current model that owns the property.
-
#default_model ⇒ Object
Allow for a model property to be defined with a block initialization or a default hash.
Methods inherited from Property
define_property, defined_properties, get, #get, get_or_set, gets, hash_with_default_to_nil, inherited, #initialize, properties, properties_hash, property, #set, set, sets
Constructor Details
This class inherits a constructor from Metro::Model::Property
Instance Method Details
#create_model ⇒ Metro::Model
Return a model created by the current model that owns the property.
77 78 79 |
# File 'lib/metro/models/properties/model_property.rb', line 77 def create_model model.create params[:model], params.except(:model) end |
#default_model ⇒ Object
Allow for a model property to be defined with a block initialization or a default hash.
67 68 69 70 71 72 73 |
# File 'lib/metro/models/properties/model_property.rb', line 67 def default_model if block model.instance_eval(&block) else create_model [:default] end end |