Class: ROM::Options::Option Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rom/support/options.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defines a single option

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Option

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Option.



47
48
49
50
51
52
53
54
55
56
# File 'lib/rom/support/options.rb', line 47

def initialize(name, options = {})
  @name   = name
  @reader = options.fetch(:reader) { false }
  # Prepares transformations applied by [#transform]
  add_coercer options[:coercer]
  add_default options[:default] if options.key? :default
  add_type_checker options[:type]
  add_value_checker options[:allow]
  add_reader if reader
end

Instance Attribute Details

#nameObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
# File 'lib/rom/support/options.rb', line 45

def name
  @name
end

#readerObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



45
46
47
# File 'lib/rom/support/options.rb', line 45

def reader
  @reader
end

Instance Method Details

#transform(object, options) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Takes options of some object, applies current transformations and returns updated options

Parameters:

  • object (Object)
  • options (Hash)

Returns:

  • (Hash)

    options



66
67
68
# File 'lib/rom/support/options.rb', line 66

def transform(object, options)
  transformers.inject(options) { |a, e| e[object, a] }
end