Class: Mochigome::ReportFocus
- Inherits:
-
Object
- Object
- Mochigome::ReportFocus
- Defined in:
- lib/model_extensions.rb
Instance Attribute Summary collapse
-
#type_name ⇒ Object
readonly
Returns the value of attribute type_name.
Instance Method Summary collapse
- #field_data(fieldset_names = nil) ⇒ 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.
158 159 160 161 162 163 |
# File 'lib/model_extensions.rb', line 158 def initialize(owner, settings) @owner = owner @name_proc = settings.[:name] || lambda{|obj| obj.name} @type_name = settings.[:type_name] || owner.class.human_name @fieldsets = settings.[:fieldsets] || {} end |
Instance Attribute Details
#type_name ⇒ Object (readonly)
Returns the value of attribute type_name.
156 157 158 |
# File 'lib/model_extensions.rb', line 156 def type_name @type_name end |
Instance Method Details
#field_data(fieldset_names = nil) ⇒ Object
169 170 171 172 173 174 175 176 177 |
# File 'lib/model_extensions.rb', line 169 def field_data(fieldset_names = nil) fieldset_names ||= [:default] h = ActiveSupport::OrderedHash.new field_descs = fieldset_names.map{|n|@fieldsets[n]}.compact.flatten(1).uniq field_descs.each do |field| h[field[:name]] = field[:value_func].call(@owner) end h end |
#name ⇒ Object
165 166 167 |
# File 'lib/model_extensions.rb', line 165 def name @name_proc.call(@owner) end |