Class: Greeve::Rowset
- Inherits:
-
Object
- Object
- Greeve::Rowset
- Includes:
- Enumerable, Helpers::AddAttribute
- Defined in:
- lib/greeve/rowset.rb
Overview
Represents an XML ‘rowset` element.
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
Name of the rowset.
Instance Method Summary collapse
-
#each(&block) ⇒ Object
:nodoc:.
-
#initialize(name, xml_element) { ... } ⇒ Rowset
constructor
A new instance of Rowset.
-
#inspect ⇒ Object
:nodoc:.
-
#to_a ⇒ Array
An array of rows and their non-nil attributes.
Constructor Details
#initialize(name, xml_element) { ... } ⇒ Rowset
Returns a new instance of Rowset.
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/greeve/rowset.rb', line 16 def initialize(name, xml_element, &block) @name = name @xml_element = xml_element @attributes = {} @rows = nil # Load the attribute configuration in the rowset block. instance_eval(&block) # Disable the #attribute method since the attributes have been configured. define_singleton_method(:attribute) { raise NoMethodError, "private method" } end |
Instance Attribute Details
#name ⇒ Symbol (readonly)
Returns name of the rowset.
11 12 13 |
# File 'lib/greeve/rowset.rb', line 11 def name @name end |
Instance Method Details
#each(&block) ⇒ Object
:nodoc:
30 31 32 |
# File 'lib/greeve/rowset.rb', line 30 def each(&block) rows.each(&block) end |
#inspect ⇒ Object
:nodoc:
40 41 42 |
# File 'lib/greeve/rowset.rb', line 40 def inspect "#<#{self.class.name}:#{object_id} name: #{@name}>" end |
#to_a ⇒ Array
Returns an array of rows and their non-nil attributes.
35 36 37 |
# File 'lib/greeve/rowset.rb', line 35 def to_a map(&:to_h) end |