class Calibrate::Configurable::FieldProcessor

Attributes

field_names[RW]
source[R]

Public Class Methods

new(source) click to toggle source
# File lib/calibrate/configurable/field-processor.rb, line 4
def initialize(source)
  @source = source
  @field_names = filter(source.class.field_names)
end

Public Instance Methods

can_process(field, target) click to toggle source
# File lib/calibrate/configurable/field-processor.rb, line 17
def can_process(field, target)
  target.respond_to?(field.writer_method)
end
filter(field_names) click to toggle source
# File lib/calibrate/configurable/field-processor.rb, line 11
def filter(field_names)
  field_names.find_all do |name|
    source.class.field_metadata(name).is?(filter_attribute)
  end
end
to(target) click to toggle source
# File lib/calibrate/configurable/field-processor.rb, line 21
def to(target)
  field_names.each do |name|
    field = source.class.field_metadata(name)
    next unless can_process(field, target)
    target.__send__(field.writer_method, value(field))
  end
end