Class: CollectionJSON::Query
- Inherits:
-
Hash
- Object
- Hash
- CollectionJSON::Query
- Defined in:
- lib/collection-json/attributes/query.rb
Class Method Summary collapse
Instance Method Summary collapse
- #build(params = {}) ⇒ Object
- #data ⇒ Object
- #data=(array) ⇒ Object
- #href ⇒ Object
- #href=(value) ⇒ Object
- #name ⇒ Object
- #name=(value) ⇒ Object
- #prompt ⇒ Object
- #prompt=(value) ⇒ Object
- #rel ⇒ Object
- #rel=(value) ⇒ Object
Class Method Details
.from_hash(hash) ⇒ Object
5 6 7 |
# File 'lib/collection-json/attributes/query.rb', line 5 def self.from_hash(hash) self.new.merge! hash end |
Instance Method Details
#build(params = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/collection-json/attributes/query.rb', line 29 def build(params = {}) URI(href).tap do |uri| uri.query = add_query_params(uri.query || '', params) end.to_s.gsub(/\?$/, '') end |
#data ⇒ Object
21 22 23 |
# File 'lib/collection-json/attributes/query.rb', line 21 def data self['data'].map {|data| Data.from_hash(data)} end |
#data=(array) ⇒ Object
25 26 27 |
# File 'lib/collection-json/attributes/query.rb', line 25 def data=(array) self['data'] = array end |
#href ⇒ Object
9 |
# File 'lib/collection-json/attributes/query.rb', line 9 def href; self['href']; end |
#href=(value) ⇒ Object
10 |
# File 'lib/collection-json/attributes/query.rb', line 10 def href=(value); self['href'] = value; end |
#name ⇒ Object
15 |
# File 'lib/collection-json/attributes/query.rb', line 15 def name; self['name']; end |
#name=(value) ⇒ Object
16 |
# File 'lib/collection-json/attributes/query.rb', line 16 def name=(value); self['name'] = value; end |
#prompt ⇒ Object
18 |
# File 'lib/collection-json/attributes/query.rb', line 18 def prompt; self['prompt']; end |
#prompt=(value) ⇒ Object
19 |
# File 'lib/collection-json/attributes/query.rb', line 19 def prompt=(value); self['prompt'] = value; end |
#rel ⇒ Object
12 |
# File 'lib/collection-json/attributes/query.rb', line 12 def rel; self['rel']; end |
#rel=(value) ⇒ Object
13 |
# File 'lib/collection-json/attributes/query.rb', line 13 def rel=(value); self['rel'] = value; end |