class Flatter::Mapping

Attributes

mapper[R]
name[R]
options[R]
target_attribute[R]

Public Class Methods

new(mapper, name, target_attribute, **options) click to toggle source
# File lib/flatter/mapping.rb, line 12
def initialize(mapper, name, target_attribute, **options)
  @mapper           = mapper
  @name             = name.to_s
  @target_attribute = target_attribute
  @options          = options
end

Public Instance Methods

read() click to toggle source
# File lib/flatter/mapping.rb, line 19
def read
  read!
end
read!() click to toggle source
# File lib/flatter/mapping.rb, line 23
def read!
  target.public_send(target_attribute)
end
read_as_params() click to toggle source
# File lib/flatter/mapping.rb, line 35
def read_as_params
  {name => read}
end
write(value) click to toggle source
# File lib/flatter/mapping.rb, line 27
def write(value)
  write!(value)
end
write!(value) click to toggle source
# File lib/flatter/mapping.rb, line 31
def write!(value)
  target.public_send("#{target_attribute}=", value)
end
write_from_params(params) click to toggle source
# File lib/flatter/mapping.rb, line 39
def write_from_params(params)
  write(params[name]) if params.key?(name)
end