Class: ODFReport::DataSource
- Inherits:
-
Object
- Object
- ODFReport::DataSource
- Defined in:
- lib/odf-report/data_source.rb
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(opts, &block) ⇒ DataSource
constructor
A new instance of DataSource.
- #set_source(record) ⇒ Object
Constructor Details
#initialize(opts, &block) ⇒ DataSource
Returns a new instance of DataSource.
6 7 8 9 10 |
# File 'lib/odf-report/data_source.rb', line 6 def initialize(opts, &block) @value = opts[:value] || opts[:collection] @data_field = opts[:data_field] || opts[:collection_field] || opts[:name] @block = block end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/odf-report/data_source.rb', line 4 def value @value end |
Instance Method Details
#each(&block) ⇒ Object
16 17 18 19 |
# File 'lib/odf-report/data_source.rb', line 16 def each(&block) return unless @value @value.each(&block) end |
#empty? ⇒ Boolean
21 22 23 |
# File 'lib/odf-report/data_source.rb', line 21 def empty? @value.nil? || @value.empty? end |
#set_source(record) ⇒ Object
12 13 14 |
# File 'lib/odf-report/data_source.rb', line 12 def set_source(record) @value = extract_value_from_item(record) end |