module Flatter::Mapping::Scribe
Constants
- BadWriterError
Public Instance Methods
arity_of(obj)
click to toggle source
# File lib/flatter/mapping/scribe.rb, line 38 def arity_of(obj) (obj.is_a?(Proc) ? obj : mapper.method(obj)).arity end
exec_or_send(obj, args)
click to toggle source
# File lib/flatter/mapping/scribe.rb, line 43 def exec_or_send(obj, args) if obj.is_a?(Proc) mapper.instance_exec(*args, &obj) else mapper.send(obj, *args) end end
read()
click to toggle source
Calls superclass method
# File lib/flatter/mapping/scribe.rb, line 10 def read return super unless reader? case reader when Proc, Symbol args = Array((name if arity_of(reader) == 1)) exec_or_send(reader, args) when false then nil else reader end end
read_as_params()
click to toggle source
Calls superclass method
# File lib/flatter/mapping/scribe.rb, line 34 def read_as_params reader == false ? {} : super end
write(value)
click to toggle source
Calls superclass method
# File lib/flatter/mapping/scribe.rb, line 22 def write(value) return super unless writer? case writer when Proc, Symbol args = [value].tap{ |a| a << name if arity_of(writer) == 2 } exec_or_send(writer, args) when false then nil else fail BadWriterError, "cannot use #{writer.inspect} for assigning values" end end