Module: Trackman::Assets::Persistence::Remote::ClassMethods
- Defined in:
- lib/trackman/assets/persistence/remote.rb
Instance Method Summary collapse
Instance Method Details
#all ⇒ Object
28 29 30 |
# File 'lib/trackman/assets/persistence/remote.rb', line 28 def all get_attributes.map{ |r| create(r) }.sort end |
#find(id) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/trackman/assets/persistence/remote.rb', line 20 def find id response = RestClient.get "#{site}/#{id}" body = Hash[JSON.parse(response).map{ |k, v| [k.to_sym, v] }] create(body) end |
#get_attributes ⇒ Object
32 33 34 |
# File 'lib/trackman/assets/persistence/remote.rb', line 32 def get_attributes JSON.parse(RestClient.get site).map{|r| Hash[r.map{ |k, v| [k.to_sym, v] }] } end |
#server_url ⇒ Object
13 14 15 |
# File 'lib/trackman/assets/persistence/remote.rb', line 13 def server_url @server_url ||= ENV['TRACKMAN_URL'] end |
#site ⇒ Object
16 17 18 |
# File 'lib/trackman/assets/persistence/remote.rb', line 16 def site @site ||= "#{server_url}/assets" end |