Class: MagicReport::Report::Builder::HasOne
- Inherits:
-
Object
- Object
- MagicReport::Report::Builder::HasOne
- Defined in:
- lib/magic_report/report/builder/has_one.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#extension ⇒ Object
readonly
Returns the value of attribute extension.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
-
#report ⇒ Object
readonly
Returns the value of attribute report.
Class Method Summary collapse
Instance Method Summary collapse
- #build_row ⇒ Object
-
#initialize(report, name, options, extension) ⇒ HasOne
constructor
A new instance of HasOne.
- #process(model) ⇒ Object
- #process_rows(model, row) ⇒ Object
Constructor Details
#initialize(report, name, options, extension) ⇒ HasOne
Returns a new instance of HasOne.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/magic_report/report/builder/has_one.rb', line 13 def initialize(report, name, , extension) @report = report @name = name @options = @extension = extension @prefix = I18n.t!("#{report.i18n_scope}.#{report.i18n_key}.#{name}_relation") unless [:class] klass = ::MagicReport::Report.clone klass.define_singleton_method(:name) { "#{report.name}/#{name}" } klass.class_eval(&extension) [:class] = klass end end |
Instance Attribute Details
#extension ⇒ Object (readonly)
Returns the value of attribute extension.
11 12 13 |
# File 'lib/magic_report/report/builder/has_one.rb', line 11 def extension @extension end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/magic_report/report/builder/has_one.rb', line 11 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/magic_report/report/builder/has_one.rb', line 11 def @options end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
11 12 13 |
# File 'lib/magic_report/report/builder/has_one.rb', line 11 def prefix @prefix end |
#report ⇒ Object (readonly)
Returns the value of attribute report.
11 12 13 |
# File 'lib/magic_report/report/builder/has_one.rb', line 11 def report @report end |
Class Method Details
.build(report, name, options, &extension) ⇒ Object
7 8 9 |
# File 'lib/magic_report/report/builder/has_one.rb', line 7 def self.build(report, name, , &extension) new(report, name, , extension) end |
Instance Method Details
#build_row ⇒ Object
43 44 45 |
# File 'lib/magic_report/report/builder/has_one.rb', line 43 def build_row [:class].build_row(prefix) end |
#process(model) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/magic_report/report/builder/has_one.rb', line 29 def process(model) relation = extract_relation(model) # Refactor here values method call [:class].new(relation).values end |
#process_rows(model, row) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/magic_report/report/builder/has_one.rb', line 36 def process_rows(model, row) relation = extract_relation(model) # Refactor here values method call [:class].new(relation, row).rows end |