Class: Objectmancy::AttributeOptions
- Inherits:
-
Object
- Object
- Objectmancy::AttributeOptions
- Defined in:
- lib/objectmancy/attribute_options.rb
Overview
Class to contain the options for attribute definitions. Makes accessing them more Object-Oriented. This could be written with Objectable, but that felt a little too on-the-nose.
Instance Attribute Summary collapse
-
#hashable ⇒ Object
readonly
Returns the value of attribute hashable.
- #multiple ⇒ Object readonly
- #objectable ⇒ Object readonly
- #type ⇒ Object readonly
Instance Method Summary collapse
-
#force_singular ⇒ AttributeOptions
Returns a new copy of of the given object without a value for the multiple attribute.
-
#initialize(**options) ⇒ AttributeOptions
constructor
A new instance of AttributeOptions.
Constructor Details
#initialize(**options) ⇒ AttributeOptions
Returns a new instance of AttributeOptions.
13 14 15 16 17 18 |
# File 'lib/objectmancy/attribute_options.rb', line 13 def initialize(**) @type = [:type] @objectable = [:objectable] @multiple = [:multiple] @hashable = [:hashable] end |
Instance Attribute Details
#hashable ⇒ Object (readonly)
Returns the value of attribute hashable.
11 |
# File 'lib/objectmancy/attribute_options.rb', line 11 attr_reader :type, :objectable, :multiple, :hashable |
#multiple ⇒ Object (readonly)
11 |
# File 'lib/objectmancy/attribute_options.rb', line 11 attr_reader :type, :objectable, :multiple, :hashable |
#objectable ⇒ Object (readonly)
11 |
# File 'lib/objectmancy/attribute_options.rb', line 11 attr_reader :type, :objectable, :multiple, :hashable |
#type ⇒ Object (readonly)
11 12 13 |
# File 'lib/objectmancy/attribute_options.rb', line 11 def type @type end |
Instance Method Details
#force_singular ⇒ AttributeOptions
Returns a new copy of of the given object without a value for the multiple attribute.
24 25 26 |
# File 'lib/objectmancy/attribute_options.rb', line 24 def force_singular AttributeOptions.new(type: type, hashable: hashable) end |