Module: Jaysus::Remote::ClassMethods

Defined in:
lib/jaysus/remote.rb

Instance Method Summary collapse

Instance Method Details

#allObject



55
56
57
58
59
60
61
62
63
# File 'lib/jaysus/remote.rb', line 55

def all
  records = []
  ActiveSupport::JSON.decode(RestClient.get(model_url,{
    'Accept' => 'application/json'
  })).each do |raw_record|
    records << new(raw_record[self.singular_object_name])
  end
  records
end

#find(id) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/jaysus/remote.rb', line 65

def find(id)
  super do
    RestClient.get("#{model_url}/#{id}",{
      'Accept' => 'application/json'
    })
  end
end

#model_urlObject



51
52
53
# File 'lib/jaysus/remote.rb', line 51

def model_url
  "#{Jaysus::Remote.base_url}/#{self.plural_object_name}"
end