Class: Mochigome::ReportFocus
- Inherits:
-
Object
- Object
- Mochigome::ReportFocus
- Defined in:
- lib/model_extensions.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#type_name ⇒ Object
readonly
Returns the value of attribute type_name.
Instance Method Summary collapse
- #field_data ⇒ Object
-
#initialize(owner, settings) ⇒ ReportFocus
constructor
A new instance of ReportFocus.
- #name ⇒ Object
Constructor Details
#initialize(owner, settings) ⇒ ReportFocus
Returns a new instance of ReportFocus.
129 130 131 132 133 134 |
# File 'lib/model_extensions.rb', line 129 def initialize(owner, settings) @owner = owner @name_proc = settings.[:name] || lambda{|obj| obj.name} @type_name = settings.[:type_name] || owner.class.human_name @fields = settings.[:fields] || [] end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
127 128 129 |
# File 'lib/model_extensions.rb', line 127 def fields @fields end |
#type_name ⇒ Object (readonly)
Returns the value of attribute type_name.
126 127 128 |
# File 'lib/model_extensions.rb', line 126 def type_name @type_name end |
Instance Method Details
#field_data ⇒ Object
140 141 142 143 144 145 146 |
# File 'lib/model_extensions.rb', line 140 def field_data h = ActiveSupport::OrderedHash.new self.fields.each do |field| h[field[:name]] = field[:value_func].call(@owner) end h end |
#name ⇒ Object
136 137 138 |
# File 'lib/model_extensions.rb', line 136 def name @name_proc.call(@owner) end |