Class: Graft::Json::Attribute
- Inherits:
-
Object
- Object
- Graft::Json::Attribute
- Defined in:
- lib/graft/lib/graft/json/attribute.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(name, source = nil) ⇒ Attribute
constructor
A new instance of Attribute.
- #value_from(data) ⇒ Object
Constructor Details
#initialize(name, source = nil) ⇒ Attribute
Returns a new instance of Attribute.
7 8 9 10 |
# File 'lib/graft/lib/graft/json/attribute.rb', line 7 def initialize(name, source = nil) @name = name @source = source.nil? ? @name.to_s : source end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/graft/lib/graft/json/attribute.rb', line 5 def name @name end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/graft/lib/graft/json/attribute.rb', line 5 def source @source end |
Instance Method Details
#value_from(data) ⇒ Object
12 13 14 |
# File 'lib/graft/lib/graft/json/attribute.rb', line 12 def value_from(data) data/source end |