Class: ActiveAttr::AttributeDefinition
- Inherits:
-
Object
- Object
- ActiveAttr::AttributeDefinition
- Includes:
- Comparable
- Defined in:
- lib/active_attr/attribute_definition.rb
Overview
Represents an attribute for reflection
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
The attribute name.
Instance Method Summary collapse
-
#<=>(other) ⇒ -1, ...
Compare attribute definitions.
-
#initialize(name, options = {}) ⇒ ActiveAttr::AttributeDefinition
constructor
Creates a new AttributeDefinition.
-
#to_s ⇒ String
(also: #inspect)
The attribute name.
-
#to_sym ⇒ Symbol
The attribute name.
Constructor Details
#initialize(name, options = {}) ⇒ ActiveAttr::AttributeDefinition
Creates a new AttributeDefinition
40 41 42 43 |
# File 'lib/active_attr/attribute_definition.rb', line 40 def initialize(name, ={}) raise TypeError, "can't convert #{name.class} into Symbol" unless name.respond_to? :to_sym @name = name.to_sym end |
Instance Attribute Details
#name ⇒ Object (readonly)
The attribute name
13 14 15 |
# File 'lib/active_attr/attribute_definition.rb', line 13 def name @name end |
Instance Method Details
#<=>(other) ⇒ -1, ...
Compare attribute definitions
25 26 27 28 |
# File 'lib/active_attr/attribute_definition.rb', line 25 def <=>(other) return nil unless other.instance_of? self.class self.name.to_s <=> other.name.to_s end |
#to_s ⇒ String Also known as: inspect
The attribute name
50 51 52 |
# File 'lib/active_attr/attribute_definition.rb', line 50 def to_s name.to_s end |
#to_sym ⇒ Symbol
The attribute name
60 61 62 |
# File 'lib/active_attr/attribute_definition.rb', line 60 def to_sym name end |