Class: Virtus::PendingAttribute
- Inherits:
-
Object
- Object
- Virtus::PendingAttribute
- Defined in:
- lib/virtus/attribute/builder.rb
Overview
Attribute placeholder used when type constant is passed as a string or symbol
Instance Attribute Summary collapse
- #name ⇒ Object readonly
- #options ⇒ Object readonly
- #type ⇒ Object readonly
Instance Method Summary collapse
- #determine_type ⇒ Object private
- #finalize ⇒ Object private
- #finalized? ⇒ Boolean private
-
#initialize(type, options) ⇒ PendingAttribute
constructor
private
A new instance of PendingAttribute.
Constructor Details
#initialize(type, options) ⇒ PendingAttribute
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 PendingAttribute.
10 11 12 13 |
# File 'lib/virtus/attribute/builder.rb', line 10 def initialize(type, ) @type, @options = type.to_s, @name = [:name] end |
Instance Attribute Details
#name ⇒ Object (readonly)
7 8 9 |
# File 'lib/virtus/attribute/builder.rb', line 7 def name @name end |
#options ⇒ Object (readonly)
7 8 9 |
# File 'lib/virtus/attribute/builder.rb', line 7 def @options end |
#type ⇒ Object (readonly)
7 8 9 |
# File 'lib/virtus/attribute/builder.rb', line 7 def type @type end |
Instance Method Details
#determine_type ⇒ 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.
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/virtus/attribute/builder.rb', line 26 def determine_type if type.include?('::') # TODO: wrap it up in Virtus.constantize and use feature-detection to # pick up either Inflecto or ActiveSupport, whateve is available if defined?(Inflecto) Inflecto.constantize(type) else raise NotImplementedError, 'Virtus needs inflecto gem to constantize namespaced constant names' end else Object.const_get(type) end end |
#finalize ⇒ 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.
16 17 18 |
# File 'lib/virtus/attribute/builder.rb', line 16 def finalize Attribute::Builder.call(determine_type, ).finalize end |
#finalized? ⇒ 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.
21 22 23 |
# File 'lib/virtus/attribute/builder.rb', line 21 def finalized? false end |