Class: Api
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Api
- Defined in:
- lib/magis/web.rb,
lib/magis/collections.rb
Instance Method Summary collapse
- #current_resource ⇒ Object
- #current_user ⇒ Object
- #faye_client ⇒ Object
- #fix_id(local_object) ⇒ Object
- #friends ⇒ Object
- #pass ⇒ Object
- #process_json(local_object) ⇒ Object
- #resource_name ⇒ Object
Instance Method Details
#current_resource ⇒ Object
61 62 63 |
# File 'lib/magis/collections.rb', line 61 def current_resource @collection.source end |
#current_user ⇒ Object
125 126 127 128 |
# File 'lib/magis/web.rb', line 125 def current_user @user ||= Magis.db["users"].find(_id: session[:user_id]).to_a.first || Hash.new @user end |
#faye_client ⇒ Object
77 78 79 |
# File 'lib/magis/collections.rb', line 77 def faye_client Faye::Client.new(request.base_url+'/faye') end |
#fix_id(local_object) ⇒ Object
65 66 67 68 |
# File 'lib/magis/collections.rb', line 65 def fix_id(local_object) local_object["_id"] = local_object["_id"].to_s local_object end |
#friends ⇒ Object
130 131 132 133 134 135 |
# File 'lib/magis/web.rb', line 130 def friends Array.new if current_user["provider"].to_s == "facebook" @friends ||= FBTether.friends(current_user) end end |
#pass ⇒ Object
53 54 55 |
# File 'lib/magis/collections.rb', line 53 def pass halt [ 401, {error: "Not Found"}.to_json ] end |
#process_json(local_object) ⇒ Object
69 70 71 |
# File 'lib/magis/collections.rb', line 69 def process_json(local_object) fix_id(local_object).to_json end |
#resource_name ⇒ Object
57 58 59 |
# File 'lib/magis/collections.rb', line 57 def resource_name params[:resource] end |