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
- #allow ⇒ Object readonly private
- #default ⇒ Object readonly private
- #name ⇒ Object readonly private
- #type ⇒ Object readonly private
Instance Method Summary collapse
- #allow?(value) ⇒ Boolean private
- #assign_reader_value(object, value) ⇒ Object private
- #default? ⇒ Boolean private
- #default_value(object) ⇒ Object private
-
#initialize(name, options = {}) ⇒ Option
constructor
private
A new instance of Option.
- #reader? ⇒ Boolean private
- #type_matches?(value) ⇒ Boolean private
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.
45 46 47 48 49 50 51 52 |
# File 'lib/rom/support/options.rb', line 45 def initialize(name, = {}) @name = name @type = .fetch(:type) { Object } @reader = .fetch(:reader) { false } @allow = .fetch(:allow) { [] } @default = .fetch(:default) { Undefined } @ivar = :"@#{name}" if @reader end |
Instance Attribute Details
#allow ⇒ 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.
43 44 45 |
# File 'lib/rom/support/options.rb', line 43 def allow @allow end |
#default ⇒ 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.
43 44 45 |
# File 'lib/rom/support/options.rb', line 43 def default @default end |
#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.
43 44 45 |
# File 'lib/rom/support/options.rb', line 43 def name @name end |
#type ⇒ 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.
43 44 45 |
# File 'lib/rom/support/options.rb', line 43 def type @type end |
Instance Method Details
#allow?(value) ⇒ Boolean
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.
74 75 76 |
# File 'lib/rom/support/options.rb', line 74 def allow?(value) allow.empty? || allow.include?(value) end |
#assign_reader_value(object, value) ⇒ 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.
58 59 60 |
# File 'lib/rom/support/options.rb', line 58 def assign_reader_value(object, value) object.instance_variable_set(@ivar, value) end |
#default? ⇒ Boolean
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.
62 63 64 |
# File 'lib/rom/support/options.rb', line 62 def default? @default != Undefined end |
#default_value(object) ⇒ 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.
66 67 68 |
# File 'lib/rom/support/options.rb', line 66 def default_value(object) default.is_a?(Proc) ? default.call(object) : default end |
#reader? ⇒ Boolean
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.
54 55 56 |
# File 'lib/rom/support/options.rb', line 54 def reader? @reader end |
#type_matches?(value) ⇒ Boolean
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.
70 71 72 |
# File 'lib/rom/support/options.rb', line 70 def type_matches?(value) value.is_a?(type) end |