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:



151
152
153
# File 'lib/rom/support/options.rb', line 151

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.



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

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



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

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