Class: CollectionJSON::ItemBuilder
- Inherits:
-
Object
- Object
- CollectionJSON::ItemBuilder
- Defined in:
- lib/collection-json/builder.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
Instance Method Summary collapse
- #add_data(name, params = {}) ⇒ Object
- #add_link(href, rel, params = {}) ⇒ Object
-
#initialize(data, links) ⇒ ItemBuilder
constructor
A new instance of ItemBuilder.
Constructor Details
#initialize(data, links) ⇒ ItemBuilder
Returns a new instance of ItemBuilder.
54 55 56 57 |
# File 'lib/collection-json/builder.rb', line 54 def initialize(data, links) @data = data @links = links end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
52 53 54 |
# File 'lib/collection-json/builder.rb', line 52 def data @data end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
52 53 54 |
# File 'lib/collection-json/builder.rb', line 52 def links @links end |
Instance Method Details
#add_data(name, params = {}) ⇒ Object
59 60 61 62 |
# File 'lib/collection-json/builder.rb', line 59 def add_data(name, params = {}) params.merge!({'name' => name}) data << params end |
#add_link(href, rel, params = {}) ⇒ Object
64 65 66 67 |
# File 'lib/collection-json/builder.rb', line 64 def add_link(href, rel, params = {}) params.merge!({'rel' => rel, 'href' => href}) links << params end |