Class: AttributesDSL::Attribute Private
- Inherits:
-
Object
- Object
- AttributesDSL::Attribute
- Defined in:
- lib/attributes_dsl/attribute.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.
Describes settings for PORO attribute
Instance Attribute Summary collapse
-
#name ⇒ Symbol
readonly
private
The name of the attribute.
-
#reader ⇒ Boolean
readonly
private
Whether an attribute should be readable.
Instance Method Summary collapse
-
#initialize(name, options = {}, &coercer) ⇒ Attribute
constructor
private
Initializes the attribute.
-
#transformer ⇒ Proc
private
A proc that transform a hash of attributes using current settings.
Constructor Details
#initialize(name, options = {}, &coercer) ⇒ Attribute
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.
Initializes the attribute
32 33 34 35 36 |
# File 'lib/attributes_dsl/attribute.rb', line 32 def initialize(name, = {}, &coercer) @name = name.to_sym = { coercer: coercer }.merge() @reader = .fetch(:reader) { true } end |
Instance Attribute Details
#name ⇒ Symbol (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.
Returns the name of the attribute.
18 19 20 |
# File 'lib/attributes_dsl/attribute.rb', line 18 def name @name end |
#reader ⇒ Boolean (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.
Returns whether an attribute should be readable.
24 25 26 |
# File 'lib/attributes_dsl/attribute.rb', line 24 def reader @reader end |
Instance Method Details
#transformer ⇒ Proc
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.
A proc that transform a hash of attributes using current settings
42 43 44 |
# File 'lib/attributes_dsl/attribute.rb', line 42 def transformer convert unless .empty? end |