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, #destroy, #destroyed?, find, #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



9
10
11
# File 'lib/user.rb', line 9

def current
  @current
end

.log_in(login, password) ⇒ Object

authenticate user credentials



14
15
16
17
18
19
# File 'lib/user.rb', line 14

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 =



24
25
26
27
# File 'lib/user.rb', line 24

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

Instance Method Details

#commentsObject



46
47
48
# File 'lib/user.rb', line 46

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

#filesObject



50
51
52
# File 'lib/user.rb', line 50

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

#flowsObject

Associations =



38
39
40
# File 'lib/user.rb', line 38

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

#logged_in?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/user.rb', line 54

def logged_in?
  @current
end

#postsObject



42
43
44
# File 'lib/user.rb', line 42

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