Class: Array
Instance Method Summary collapse
- #to_object(subject = Object.new) ⇒ Object
- #to_objects(type = Object, &block_that_returns_the_records) ⇒ Object
Instance Method Details
#to_object(subject = Object.new) ⇒ Object
3 4 5 6 |
# File 'lib/subtle/array_to_objects.rb', line 3 def to_object(subject = Object.new) self.each { |field| add_attr_accessor_for(subject, field) } subject end |
#to_objects(type = Object, &block_that_returns_the_records) ⇒ Object
8 9 10 11 12 |
# File 'lib/subtle/array_to_objects.rb', line 8 def to_objects(type = Object, &block_that_returns_the_records) records = block_that_returns_the_records.call return [] if records.empty? records.map { |record| turn_this_data_into_a_filled_object(type, record) } end |