Module: CollectionJSON
- Defined in:
- lib/collection-json.rb,
lib/collection-json/builder.rb,
lib/collection-json/version.rb,
lib/collection-json/collection.rb,
lib/collection-json/attributes/data.rb,
lib/collection-json/attributes/item.rb,
lib/collection-json/attributes/link.rb,
lib/collection-json/attributes/error.rb,
lib/collection-json/attributes/query.rb,
lib/collection-json/attributes/template.rb
Defined Under Namespace
Classes: Builder, Collection, Data, Error, Item, ItemBuilder, Link, Query, QueryBuilder, Template, TemplateBuilder
Constant Summary
collapse
- VERSION =
"0.0.3"
Class Method Summary
collapse
Class Method Details
.add_host(href) ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/collection-json.rb', line 22
def self.add_host(href)
if ENV['COLLECTION_JSON_HOST'] && !href[/^http/]
ENV['COLLECTION_JSON_HOST'] + href
else
href
end
end
|
.generate_for(href, &block) ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/collection-json.rb', line 12
def self.generate_for(href, &block)
response = Collection.new(href)
if block_given?
builder = Builder.new(response)
yield(builder)
end
response
end
|
.parse(json) ⇒ Object
30
31
32
33
|
# File 'lib/collection-json.rb', line 30
def self.parse(json)
hash = JSON.parse(json)
collection = Collection.from_hash(hash)
end
|