Class: Mobility::Wrapper
- Defined in:
- lib/mobility/wrapper.rb
Overview
Class to access Mobility across backends. In particular, keeps a record of which Attributes modules have been included on the model class. It is also a simple delegator, so any missing method will be delegated to the model class.
Instance Attribute Summary collapse
- #modules ⇒ Array<Attributes> readonly
Instance Method Summary collapse
-
#<<(backend_module) ⇒ Object
Appends backend module to
modules
array for later reference. -
#initialize(model_class) ⇒ Wrapper
constructor
A new instance of Wrapper.
-
#translated_attribute_names ⇒ Array<String>
Translated attributes defined on model.
Constructor Details
#initialize(model_class) ⇒ Wrapper
Returns a new instance of Wrapper.
15 16 17 18 |
# File 'lib/mobility/wrapper.rb', line 15 def initialize(model_class) super @modules = [] end |
Instance Attribute Details
#modules ⇒ Array<Attributes> (readonly)
11 12 13 |
# File 'lib/mobility/wrapper.rb', line 11 def modules @modules end |
Instance Method Details
#<<(backend_module) ⇒ Object
Appends backend module to modules
array for later reference.
27 28 29 |
# File 'lib/mobility/wrapper.rb', line 27 def << backend_module modules << backend_module end |
#translated_attribute_names ⇒ Array<String>
Returns Translated attributes defined on model.
21 22 23 |
# File 'lib/mobility/wrapper.rb', line 21 def translated_attribute_names modules.map(&:attributes).flatten end |