Class: Greeve::Rowset
- Inherits:
-
Object
- Object
- Greeve::Rowset
- Includes:
- Enumerable
- 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
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/greeve/rowset.rb', line 14 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
9 10 11 |
# File 'lib/greeve/rowset.rb', line 9 def name @name end |
Instance Method Details
#each(&block) ⇒ Object
:nodoc:
28 29 30 |
# File 'lib/greeve/rowset.rb', line 28 def each(&block) rows.each(&block) end |
#inspect ⇒ Object
:nodoc:
38 39 40 |
# File 'lib/greeve/rowset.rb', line 38 def inspect "#<#{self.class.name}:#{object_id} name: #{@name}>" end |
#to_a ⇒ Array
Returns an array of rows and their non-nil attributes
33 34 35 |
# File 'lib/greeve/rowset.rb', line 33 def to_a map(&:to_h) end |