Module: ROM::Options::ClassMethods Private

Defined in:
lib/rom/support/options.rb

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#option_definitionsDefinitions

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.

Available options

Returns:



149
150
151
# File 'lib/rom/support/options.rb', line 149

def option_definitions
  @option_definitions
end

Instance Method Details

#inherited(descendant) ⇒ Object

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.



170
171
172
173
# File 'lib/rom/support/options.rb', line 170

def inherited(descendant)
  descendant.option_definitions = option_definitions.dup
  super
end

#option(name, settings = {}) ⇒ Object

Defines an option

Parameters:

  • name (Symbol)

    option name

  • settings (Hash) (defaults to: {})

    option settings

Options Hash (settings):

  • :type (Class)

    Restrict option type. Default: Object

  • :reader (Boolean)

    Define a reader? Default: false

  • :allow (Array)

    Allow certain values. Default: Allow anything

  • :default (Object)

    Set default value for missing option

  • :coercer (Proc)

    Set coercer for assigned option



163
164
165
166
167
# File 'lib/rom/support/options.rb', line 163

def option(name, settings = {})
  option = Option.new(name, settings)
  option_definitions.define(option)
  attr_reader(name) if option.reader
end