Class: Little::Tag
- Inherits:
-
Object
- Object
- Little::Tag
- Defined in:
- lib/little/tag.rb
Overview
add, delete and retrieve tags by user or assets
Class Method Summary collapse
-
.add(user, asset, type, share, data = nil) ⇒ Object
adds a tag for a user to an asset.
-
.delete(id) ⇒ Object
removes a tag for a user to an asset.
-
.for_asset(asset, type, page, records) ⇒ Object
gets all the shared tags for a specific asset.
-
.for_asset_count(asset, type) ⇒ Object
gets the number of shared tags for a specific asset.
-
.for_user(user, page, records, shared_only = true) ⇒ Object
gets all the tags for a user.
-
.for_user_and_asset(user, asset, type, page, records, shared_only = true) ⇒ Object
gets all the assets liked for a user for a specific asset.
-
.for_user_and_asset_count(user, asset, type, shared_only = true) ⇒ Object
gets all the of tags for a user for a specific asset.
-
.for_user_count(user, shared_only = true) ⇒ Object
gets the number of tags for a user.
-
.get_by_id(id, shared_only = true) ⇒ Object
gets a tag by id.
-
.sign_add(user, asset, type) ⇒ Object
generates a signature for adding a tag (useful when using the javascript library).
-
.sign_delete(id) ⇒ Object
generates a signature for deleting a tag (useful when using the javascript library).
-
.sign_for_user(user) ⇒ Object
generates a signature for getting a tags for a user (useful when using the javascript library).
-
.sign_for_user_and_asset(user, asset, type) ⇒ Object
generates a signature for getting a for a user for a specific asset (useful when using the javascript library).
-
.sign_get_by_id(id) ⇒ Object
generates a signature for getting a tag by id (useful when using the javascript library).
Class Method Details
.add(user, asset, type, share, data = nil) ⇒ Object
adds a tag for a user to an asset
10 11 12 13 14 |
# File 'lib/little/tag.rb', line 10 def self.add(user, asset, type, share, data = nil) d = {:user => user, :asset => asset, :share => share, :type => type} d[:data] = data if data Little.post(:tags, d, [:user, :asset, :type]) end |
.delete(id) ⇒ Object
removes a tag for a user to an asset
23 24 25 |
# File 'lib/little/tag.rb', line 23 def self.delete(id) Little.delete(:tags, {:id => id, :verify => 'kludge'}, [:id, :verify]) end |
.for_asset(asset, type, page, records) ⇒ Object
gets all the shared tags for a specific asset
79 80 81 |
# File 'lib/little/tag.rb', line 79 def self.for_asset(asset, type, page, records) Little.get(:tags, {:asset => asset, :type => type, :page => page, :records => records}) end |
.for_asset_count(asset, type) ⇒ Object
gets the number of shared tags for a specific asset
84 85 86 |
# File 'lib/little/tag.rb', line 84 def self.for_asset_count(asset, type) Little.get(:tags, {:asset => asset, :type => type, :count => true}) end |
.for_user(user, page, records, shared_only = true) ⇒ Object
gets all the tags for a user
45 46 47 48 |
# File 'lib/little/tag.rb', line 45 def self.for_user(user, page, records, shared_only = true) data = {:user => user, :page => page, :records => records} Little.get(:tags, data, shared_only ? nil : [:user]) end |
.for_user_and_asset(user, asset, type, page, records, shared_only = true) ⇒ Object
gets all the assets liked for a user for a specific asset
51 52 53 54 |
# File 'lib/little/tag.rb', line 51 def self.for_user_and_asset(user, asset, type, page, records, shared_only = true) data = {:user => user, :asset => asset, :type => type, :page => page, :records => records} Little.get(:tags, data, shared_only ? nil : [:user, :asset, :type]) end |
.for_user_and_asset_count(user, asset, type, shared_only = true) ⇒ Object
gets all the of tags for a user for a specific asset
63 64 65 66 |
# File 'lib/little/tag.rb', line 63 def self.for_user_and_asset_count(user, asset, type, shared_only = true) data = {:user => user, :asset => asset, :type => type, :count => true} Little.get(:tags, data, shared_only ? nil : [:user, :asset, :type]) end |
.for_user_count(user, shared_only = true) ⇒ Object
gets the number of tags for a user
57 58 59 60 |
# File 'lib/little/tag.rb', line 57 def self.for_user_count(user, shared_only = true) data = {:user => user, :count => true} Little.get(:tags, data, shared_only ? nil : [:user]) end |
.get_by_id(id, shared_only = true) ⇒ Object
gets a tag by id
35 36 37 |
# File 'lib/little/tag.rb', line 35 def self.get_by_id(id, shared_only = true) Little.get(:tags, {:id => id}, shared_only ? nil : [:id]) end |
.sign_add(user, asset, type) ⇒ Object
generates a signature for adding a tag (useful when using the javascript library)
17 18 19 |
# File 'lib/little/tag.rb', line 17 def self.sign_add(user, asset, type) Little.sign(:tags, {:user => user, :asset => asset, :type => type}) end |
.sign_delete(id) ⇒ Object
generates a signature for deleting a tag (useful when using the javascript library)
28 29 30 |
# File 'lib/little/tag.rb', line 28 def self.sign_delete(id) Little.sign(:tags, {:id => id, :verify => 'kludge'}) end |
.sign_for_user(user) ⇒ Object
generates a signature for getting a tags for a user (useful when using the javascript library)
69 70 71 |
# File 'lib/little/tag.rb', line 69 def self.sign_for_user(user) Little.sign(:tags, {:user => user}) end |
.sign_for_user_and_asset(user, asset, type) ⇒ Object
generates a signature for getting a for a user for a specific asset (useful when using the javascript library)
74 75 76 |
# File 'lib/little/tag.rb', line 74 def self.sign_for_user_and_asset(user, asset, type) Little.sign(:tags, {:user => user, :asset => asset, :type => type}) end |