Class: PropertyWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/togo/model/property_wrapper/property_wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#modelObject (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

#nameObject (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

#sortableObject (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

#typeObject (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_nameObject



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

#labelObject



16
17
18
# File 'lib/togo/model/property_wrapper/property_wrapper.rb', line 16

def label
  @model.property_options[@name][:label] rescue humanized_name
end