lib/mattock/configurable/field-processor.rb in mattock-0.5.3 vs lib/mattock/configurable/field-processor.rb in mattock-0.7.0

- old
+ new

@@ -6,39 +6,39 @@ @field_names = filter(source.class.field_names) end attr_accessor :field_names attr_reader :source - def filter_attribute - raise NotImplementedError - end - def filter(field_names) field_names.find_all do |name| source.class.field_metadata(name).is?(filter_attribute) end end - def value(field) - source.__send__(field.reader_method) + def can_process(field, target) + target.respond_to?(field.writer_method) end def to(target) field_names.each do |name| field = source.class.field_metadata(name) - next unless target.respond_to?(field.writer_method) + next unless can_process(field, target) target.__send__(field.writer_method, value(field)) end end end class SettingsCopier < FieldProcessor def filter_attribute :copiable end + def can_process(field, target) + super and not( field.unset_on?(source) and field.unset_on?(target) ) + end + def value(field) - field.immediate_value_on(source) + return field.copy_from(source) end end class SettingsProxier < FieldProcessor def filter_attribute