Class: PropertyWrapper
- Inherits:
-
Object
- Object
- PropertyWrapper
- Defined in:
- lib/togo/model/property_wrapper/property_wrapper.rb
Instance Attribute Summary collapse
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#sortable ⇒ Object
readonly
Returns the value of attribute sortable.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #humanized_name ⇒ Object
-
#initialize(opts = {}) ⇒ PropertyWrapper
constructor
A new instance of PropertyWrapper.
- #label ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ PropertyWrapper
Returns a new instance of PropertyWrapper.
5 6 7 8 9 10 |
# File 'lib/togo/model/property_wrapper/property_wrapper.rb', line 5 def initialize(opts = {}) @name = (opts[:property] ? opts[:property].name : opts[:name]).to_sym @model = opts[:model] @type = opts[:type] @sortable = opts[:sortable] || false end |
Instance Attribute Details
#model ⇒ Object (readonly)
Returns the value of attribute model.
3 4 5 |
# File 'lib/togo/model/property_wrapper/property_wrapper.rb', line 3 def model @model end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/togo/model/property_wrapper/property_wrapper.rb', line 3 def name @name end |
#sortable ⇒ Object (readonly)
Returns the value of attribute sortable.
3 4 5 |
# File 'lib/togo/model/property_wrapper/property_wrapper.rb', line 3 def sortable @sortable end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/togo/model/property_wrapper/property_wrapper.rb', line 3 def type @type end |
Instance Method Details
#humanized_name ⇒ Object
12 13 14 |
# File 'lib/togo/model/property_wrapper/property_wrapper.rb', line 12 def humanized_name @name.to_s.humanize.titleize rescue @name end |
#label ⇒ Object
16 17 18 |
# File 'lib/togo/model/property_wrapper/property_wrapper.rb', line 16 def label @model.[@name][:label] rescue humanized_name end |