module Parxer::RowBuilder
Public Class Methods
build(attributes)
click to toggle source
# File lib/parxer/utils/row_builder.rb, line 3 def self.build(attributes) Class.new(Parxer::Row) do def self.column_accessor(attribute) attr_accessor(attribute) unless method_defined?(attribute) rescue NameError raise Parxer::RowError.new("invalid '#{attribute}' method name") end def add_attribute(attribute, value = nil) self.class.column_accessor(attribute) send("#{attribute}=", value) if value end attributes.each do |attribute| column_accessor(attribute) end end end
column_accessor(attribute)
click to toggle source
# File lib/parxer/utils/row_builder.rb, line 5 def self.column_accessor(attribute) attr_accessor(attribute) unless method_defined?(attribute) rescue NameError raise Parxer::RowError.new("invalid '#{attribute}' method name") end
Public Instance Methods
add_attribute(attribute, value = nil)
click to toggle source
# File lib/parxer/utils/row_builder.rb, line 11 def add_attribute(attribute, value = nil) self.class.column_accessor(attribute) send("#{attribute}=", value) if value end