Module: ROM::Options
- Included in:
- ClassBuilder
- Defined in:
- lib/rom/support/options.rb
Overview
Helper module for classes with a constructor accepting option hash
This allows us to DRY up code as option hash is a very common pattern used across the codebase. It is an internal implementation detail not meant to be used outside of ROM
Defined Under Namespace
Modules: ClassMethods, Transformers Classes: Definitions, Option
Constant Summary collapse
- InvalidOptionValueError =
Class.new(StandardError)
- InvalidOptionKeyError =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#options ⇒ Hash<Option>
readonly
Option definitions.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*args) ⇒ Object
Initialize options provided as optional last argument hash.
Instance Attribute Details
#options ⇒ Hash<Option> (readonly)
Returns Option definitions.
34 35 36 |
# File 'lib/rom/support/options.rb', line 34 def @options end |
Class Method Details
.included(klass) ⇒ Object
36 37 38 39 |
# File 'lib/rom/support/options.rb', line 36 def self.included(klass) klass.extend ClassMethods klass.option_definitions = Definitions.new end |
Instance Method Details
#initialize(*args) ⇒ Object
Initialize options provided as optional last argument hash
191 192 193 194 195 |
# File 'lib/rom/support/options.rb', line 191 def initialize(*args) = args.last ? args.last.dup : {} self.class.option_definitions.process(self, ) @options = .freeze end |