Class: Mochigome::ReportFocus

Inherits:
Object
  • Object
show all
Defined in:
lib/model_extensions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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.options[:name] || lambda{|obj| obj.name}
  @type_name = settings.options[:type_name] || owner.class.human_name
  @fields = settings.options[:fields] || []
end

Instance Attribute Details

#fieldsObject (readonly)

Returns the value of attribute fields.



127
128
129
# File 'lib/model_extensions.rb', line 127

def fields
  @fields
end

#type_nameObject (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_dataObject



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

#nameObject



136
137
138
# File 'lib/model_extensions.rb', line 136

def name
  @name_proc.call(@owner)
end