Module: CreatorHelper
- Included in:
- Nfe::Reader::Cane, Nfe::Reader::Information, Nfe::Reader::Product
- Defined in:
- lib/helpers/creator_helper.rb
Instance Method Summary collapse
- #create_resource(klass, attrs = {}) ⇒ Object
- #create_resources(klass, attrs = {}) ⇒ Object
- #to_array(attrs = {}) ⇒ Object
Instance Method Details
#create_resource(klass, attrs = {}) ⇒ Object
2 3 4 5 |
# File 'lib/helpers/creator_helper.rb', line 2 def create_resource(klass, attrs = {}) return unless attrs klass.new(attrs) end |
#create_resources(klass, attrs = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/helpers/creator_helper.rb', line 7 def create_resources(klass, attrs = {}) resources = [] return resources unless attrs attrs.each do |a| resources << klass.new(a.last) end resources end |
#to_array(attrs = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/helpers/creator_helper.rb', line 19 def to_array(attrs = {}) array = [] if attrs.is_a? Array attrs.each do |hash| array << hash.map { |key, value| value } end else array << attrs.map { |key, value| value } end array end |