class TestAbstractions::Filler
Public Class Methods
build(data, form, mapping=nil)
click to toggle source
# File lib/test_abstractions/filler.rb, line 8 def self.build(data, form, mapping=nil) mapping ||= self.mapping(data, form) instance = new data, form, mapping instance end
map(attribute_name, form)
click to toggle source
# File lib/test_abstractions/filler.rb, line 23 def self.map(attribute_name, form) setter = "#{attribute_name}=" return nil unless form.respond_to? setter return attribute_name, attribute_name end
mapping(data, form)
click to toggle source
# File lib/test_abstractions/filler.rb, line 14 def self.mapping(data, form) mapping = {} data.attribute_names.each do |attribute_name| data_attribute, form_attribute = map attribute_name, form mapping[data_attribute] = form_attribute if form_attribute end mapping end
Public Instance Methods
!()
click to toggle source
# File lib/test_abstractions/filler.rb, line 30 def ! mapping.each do |data_attribute, form_attribute| copy data_attribute, form_attribute end end
copy(data_attribute, form_attribute)
click to toggle source
# File lib/test_abstractions/filler.rb, line 36 def copy(data_attribute, form_attribute) value = data.attributes[data_attribute] form.send "#{form_attribute}=", value return value, data_attribute, form_attribute end