Class: CollectionJSON::Query

Inherits:
Hash
  • Object
show all
Defined in:
lib/collection-json/attributes/query.rb

Class Method Summary collapse

Instance Method Summary collapse

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

#dataObject



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

#hrefObject



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

#nameObject



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

#promptObject



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

#relObject



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