Class: ROM::Options::Option Private
- Inherits:
-
Object
- Object
- ROM::Options::Option
- 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
- #name ⇒ Object readonly private
- #reader ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(name, options = {}) ⇒ Option
constructor
private
A new instance of Option.
-
#transform(object, options) ⇒ Hash
private
Takes options of some object, applies current transformations and returns updated options.
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, = {}) @name = name @reader = .fetch(:reader) { false } # Prepares transformations applied by [#transform] add_coercer [:coercer] add_default [:default] if .key? :default add_type_checker [:type] add_value_checker [:allow] add_reader if reader end |
Instance Attribute Details
#name ⇒ Object (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 |
#reader ⇒ Object (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
66 67 68 |
# File 'lib/rom/support/options.rb', line 66 def transform(object, ) transformers.inject() { |a, e| e[object, a] } end |