module ROM::Options::Transformers

Collection of transformers for options

Public Class Methods

coercer(_, options, name, fn) click to toggle source
# File lib/rom/support/options.rb, line 214
def self.coercer(_, options, name, fn)
  return options unless options.key?(name)
  value = options[name]
  options.merge name => fn[value]
end
default_proc(object, options, name, fn) click to toggle source
# File lib/rom/support/options.rb, line 209
def self.default_proc(object, options, name, fn)
  return options if options.key?(name)
  options.merge(name => fn.call(object))
end
default_value(_, options, name, value) click to toggle source
# File lib/rom/support/options.rb, line 204
def self.default_value(_, options, name, value)
  return options if options.key?(name)
  options.merge(name => value)
end
reader_assigner(object, options, name) click to toggle source
# File lib/rom/support/options.rb, line 243
def self.reader_assigner(object, options, name)
  object.instance_variable_set(:"@#{name}", options[name])
  options
end
type_checker(_, options, name, type) click to toggle source
# File lib/rom/support/options.rb, line 220
def self.type_checker(_, options, name, type)
  return options unless options.key?(name)
  value = options[name]

  return options if options[name].is_a?(type)
  fail(
    InvalidOptionValueError,
    "#{name.inspect}:#{value.inspect} has incorrect type" \
    " (#{type} is expected)"
  )
end
value_checker(_, options, name, list) click to toggle source
# File lib/rom/support/options.rb, line 232
def self.value_checker(_, options, name, list)
  return options unless options.key?(name)
  value = options[name]

  return options if list.include?(options[name])
  fail(
    InvalidOptionValueError,
    "#{name.inspect}:#{value.inspect} has incorrect value."
  )
end