Class: User

Inherits:
Flareshow::Resource show all
Defined in:
lib/user.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Flareshow::Resource

#cache, cache_response, #changes, create, default_params, #destroy, #destroyed?, find, first, #get, get_from_cache, #id, #initialize, list_cache, #method_missing, #method_name, #refresh, #resource_key, resource_key, #save, #set, store, #update

Constructor Details

This class inherits a constructor from Flareshow::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Flareshow::Resource

Class Method Details

.currentObject

return the current authenticated user



11
12
13
# File 'lib/user.rb', line 11

def current
  @current
end

.log_in(login, password) ⇒ Object

authenticate user credentials



16
17
18
19
20
21
# File 'lib/user.rb', line 16

def (, password)
  response = Flareshow::Service.authenticate(, password)
  user_data = response["resources"]["data"]
  Flareshow::CacheManager.assimilate_resources({resource_key => [user_data]})
  @current = User.get_from_cache(user_data["id"])
end

.logoutObject

Authentication =



26
27
28
29
# File 'lib/user.rb', line 26

def logout
  Flareshow::Service.logout
  @current = nil
end

Instance Method Details

#commentsObject



48
49
50
# File 'lib/user.rb', line 48

def comments
  Comment.find({"user_id" => ["in", id]})
end

#filesObject



52
53
54
# File 'lib/user.rb', line 52

def files
  File.find({"user_id" => ["in", id]})
end

#flowsObject

Associations =



40
41
42
# File 'lib/user.rb', line 40

def flows
  Flow.find({"user_id" => ["in", id]})
end

#logged_in?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/user.rb', line 56

def logged_in?
  @current
end

#postsObject



44
45
46
# File 'lib/user.rb', line 44

def posts
  Post.find({"user_id" => ["in", id]})
end