Class: Attribute
- Inherits:
-
Object
- Object
- Attribute
- Defined in:
- lib/active_hash_ext.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(type, name) ⇒ Attribute
constructor
A new instance of Attribute.
- #to_script ⇒ Object
Constructor Details
#initialize(type, name) ⇒ Attribute
Returns a new instance of Attribute.
82 83 84 |
# File 'lib/active_hash_ext.rb', line 82 def initialize(type, name) @name, @type = name, type end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
80 81 82 |
# File 'lib/active_hash_ext.rb', line 80 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
80 81 82 |
# File 'lib/active_hash_ext.rb', line 80 def type @type end |
Class Method Details
.parse(attribute) ⇒ Object
90 91 92 93 94 95 |
# File 'lib/active_hash_ext.rb', line 90 def self.parse(attribute) match = attribute.match(/t\.(\w+)\s+"(\w+)"/) if match Attribute.new(*match.captures) end end |
Instance Method Details
#to_script ⇒ Object
86 87 88 |
# File 'lib/active_hash_ext.rb', line 86 def to_script "#{name}:#{type}" unless ["created_at","updated_at"].include? name end |