Class: MagicReport::Report::Builder::Field
- Inherits:
-
Object
- Object
- MagicReport::Report::Builder::Field
- Defined in:
- lib/magic_report/report/builder/field.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#processor ⇒ Object
readonly
Returns the value of attribute processor.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(report, name, processor) ⇒ Field
constructor
A new instance of Field.
- #process(model) ⇒ Object
Constructor Details
#initialize(report, name, processor) ⇒ Field
Returns a new instance of Field.
13 14 15 16 17 |
# File 'lib/magic_report/report/builder/field.rb', line 13 def initialize(report, name, processor) @report = report @name = name @processor = processor end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/magic_report/report/builder/field.rb', line 11 def name @name end |
#processor ⇒ Object (readonly)
Returns the value of attribute processor.
11 12 13 |
# File 'lib/magic_report/report/builder/field.rb', line 11 def processor @processor end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
11 12 13 |
# File 'lib/magic_report/report/builder/field.rb', line 11 def report @report end |
Class Method Details
.build(report, name, processor) ⇒ Object
7 8 9 |
# File 'lib/magic_report/report/builder/field.rb', line 7 def self.build(report, name, processor) new(report, name, processor) end |
Instance Method Details
#process(model) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/magic_report/report/builder/field.rb', line 19 def process(model) value = extract_value(model) if processor.is_a? Proc processor.call(model, value) elsif processor.is_a? Symbol # Refactor report.new(nil).send(processor, model, value) else value end end |