Class: Cloth::Item
- Inherits:
-
Object
- Object
- Cloth::Item
- Defined in:
- lib/cloth/item.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
- .recommend(id, data = nil) ⇒ Object
- .recommendations(id, data = nil) ⇒ Object
- .unrecommend(id, data = nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(id, data) ⇒ Item
constructor
A new instance of Item.
- #recommend ⇒ Object
- #recommendations ⇒ Object
- #unrecommend ⇒ Object
Constructor Details
#initialize(id, data) ⇒ Item
Returns a new instance of Item.
3 4 5 6 7 |
# File 'lib/cloth/item.rb', line 3 def initialize(id, data) @id = id @data = data @user = data["user_id"] if @data && data["user_id"] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/cloth/item.rb', line 9 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/cloth/item.rb', line 10 def id @id end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
11 12 13 |
# File 'lib/cloth/item.rb', line 11 def user @user end |
Class Method Details
.recommend(id, data = nil) ⇒ Object
31 32 33 |
# File 'lib/cloth/item.rb', line 31 def recommend(id, data = nil) Item.new(id, data).recommend end |
Instance Method Details
#recommend ⇒ Object
13 14 15 |
# File 'lib/cloth/item.rb', line 13 def recommend Cloth.client.post("/api/items/recommend", { body: { item: { id: id, data: data } } }) end |