Class: Flow
- Inherits:
-
Flareshow::Resource
- Object
- Flareshow::Resource
- Flow
- Defined in:
- lib/flow.rb
Class Method Summary collapse
-
.find_by_name(name) ⇒ Object
find a flow by name.
Instance Method Summary collapse
-
#build_post(attributes) ⇒ Object
build a new post but don’t persist it immediatel.
-
#create_post(attributes) ⇒ Object
create a new post in this flow.
-
#list_invitations ⇒ Object
list the invitations to this flow.
-
#list_users ⇒ Object
list all users on the flow currently.
-
#permalink(mobile = false) ⇒ Object
permalink for this flow.
-
#posts ⇒ Object
posts for this flow…only returns the first 100 (API max) to load all posts you can interact with the Service class directly to loop through in batches of 100 using the offset parameter or create a flow object and override this method with the looping logic.
-
#remove_members(member_ids) ⇒ Object
remove a user from a flow you must be the owner of the flow to perform this action.
-
#revoke_invitations(email_addresses) ⇒ Object
uninvite an invited user from a flow by email address.
-
#send_invitations(email_addresses) ⇒ Object
invite/reinvite a user to a flow by email address.
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
.find_by_name(name) ⇒ Object
find a flow by name
11 12 13 |
# File 'lib/flow.rb', line 11 def find_by_name(name) self.first({:name => name}) end |
Instance Method Details
#build_post(attributes) ⇒ Object
build a new post but don’t persist it immediatel
46 47 48 49 50 51 |
# File 'lib/flow.rb', line 46 def build_post(attributes) post = Post.new post.update(attributes) post.flow_id = id post end |
#create_post(attributes) ⇒ Object
create a new post in this flow
54 55 56 57 |
# File 'lib/flow.rb', line 54 def create_post(attributes) p=build_post(attributes) p.save end |
#list_invitations ⇒ Object
list the invitations to this flow
68 69 70 |
# File 'lib/flow.rb', line 68 def list_invitations Invitation.find(:flow_id => id) end |
#list_users ⇒ Object
list all users on the flow currently
73 74 75 76 |
# File 'lib/flow.rb', line 73 def list_users response = Flareshow::Service.query({:flows=>{:id => self.id, :limit => 1, :include=>['users']}}) (Flareshow::CacheManager.assimilate_resources(response["resources"]) || {})["users"] end |
#permalink(mobile = false) ⇒ Object
permalink for this flow
17 18 19 20 21 22 23 |
# File 'lib/flow.rb', line 17 def permalink(mobile=false) if mobile "http://#{Flareshow::Service.server.host}/#{Flareshow::Service.server.domain}/shareflow/mobile/flows/#{id}" else "http://#{Flareshow::Service.server.host}/#{Flareshow::Service.server.domain}/shareflow/c/#{id}" end end |
#posts ⇒ Object
posts for this flow…only returns the first 100 (API max) to load all posts you can interact with the Service class directly to loop through in batches of 100 using the offset parameter or create a flow object and override this method with the looping logic
63 64 65 |
# File 'lib/flow.rb', line 63 def posts Post.find(:flow_id => id) end |
#remove_members(member_ids) ⇒ Object
remove a user from a flow you must be the owner of the flow to perform this action
40 41 42 43 |
# File 'lib/flow.rb', line 40 def remove_members(member_ids) self.remove_members = [member_ids].flatten self.save end |
#revoke_invitations(email_addresses) ⇒ Object
uninvite an invited user from a flow by email address
32 33 34 35 |
# File 'lib/flow.rb', line 32 def revoke_invitations(email_addresses) self.uninvite = [email_addresses].flatten self.save end |
#send_invitations(email_addresses) ⇒ Object
invite/reinvite a user to a flow by email address
26 27 28 29 |
# File 'lib/flow.rb', line 26 def send_invitations(email_addresses) self.invite = [email_addresses].flatten self.save end |