Class: Objectmancy::AttributeOptions

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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(**options)
  @type = options[:type]
  @objectable = options[:objectable]
  @multiple = options[:multiple]
  @hashable = options[:hashable]
end

Instance Attribute Details

#hashableObject (readonly)

Returns the value of attribute hashable.



11
# File 'lib/objectmancy/attribute_options.rb', line 11

attr_reader :type, :objectable, :multiple, :hashable

#multipleObject (readonly)



11
# File 'lib/objectmancy/attribute_options.rb', line 11

attr_reader :type, :objectable, :multiple, :hashable

#objectableObject (readonly)



11
# File 'lib/objectmancy/attribute_options.rb', line 11

attr_reader :type, :objectable, :multiple, :hashable

#typeObject (readonly)



11
12
13
# File 'lib/objectmancy/attribute_options.rb', line 11

def type
  @type
end

Instance Method Details

#force_singularAttributeOptions

Returns a new copy of of the given object without a value for the multiple attribute.

Returns:



24
25
26
# File 'lib/objectmancy/attribute_options.rb', line 24

def force_singular
  AttributeOptions.new(type: type, hashable: hashable)
end