Class: DataMapper::Parse::Engine
- Inherits:
-
Object
- Object
- DataMapper::Parse::Engine
- Defined in:
- lib/adapters/parse/engine.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #create(storage_name, attributes) ⇒ Object
- #delete(storage_name, id) ⇒ Object
-
#initialize(app_id, api_key, master) ⇒ Engine
constructor
A new instance of Engine.
- #read(storage_name, params) ⇒ Object
- #request_password_reset(email) ⇒ Object
- #sign_in(username, password) ⇒ Object
- #update(storage_name, id, attributes) ⇒ Object
- #upload_file(filename, content, content_type) ⇒ Object
Constructor Details
#initialize(app_id, api_key, master) ⇒ Engine
Returns a new instance of Engine.
35 36 37 38 |
# File 'lib/adapters/parse/engine.rb', line 35 def initialize(app_id, api_key, master) @app_id, @api_key, @master = app_id, api_key, master @client = build_client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
33 34 35 |
# File 'lib/adapters/parse/engine.rb', line 33 def client @client end |
Instance Method Details
#create(storage_name, attributes) ⇒ Object
51 52 53 |
# File 'lib/adapters/parse/engine.rb', line 51 def create(storage_name, attributes) client.post uri_for(storage_name), attributes.to_json end |
#delete(storage_name, id) ⇒ Object
47 48 49 |
# File 'lib/adapters/parse/engine.rb', line 47 def delete(storage_name, id) client.delete uri_for(storage_name, id) end |
#read(storage_name, params) ⇒ Object
40 41 42 43 44 45 |
# File 'lib/adapters/parse/engine.rb', line 40 def read(storage_name, params) query = params.inject({}) do |result, (k, v)| result.merge k.to_s => CGI.escape(v.to_s) end client.request uri_for(storage_name), :get, nil, query end |
#request_password_reset(email) ⇒ Object
68 69 70 |
# File 'lib/adapters/parse/engine.rb', line 68 def request_password_reset(email) client.post ::Parse::Protocol::PASSWORD_RESET_URI, {email: email}.to_json end |
#sign_in(username, password) ⇒ Object
59 60 61 |
# File 'lib/adapters/parse/engine.rb', line 59 def sign_in(username, password) client.request ::Parse::Protocol::USER_LOGIN_URI, :get, nil, { username: username, password: password } end |
#update(storage_name, id, attributes) ⇒ Object
55 56 57 |
# File 'lib/adapters/parse/engine.rb', line 55 def update(storage_name, id, attributes) client.put uri_for(storage_name, id), attributes.to_json end |