Class: Pinterest::Pin
Overview
A object representing a Pinterest pin.
Constant Summary collapse
- FIELDS =
The list of fields of the object.
["id", "link", "url", "creator", "board", "created_at", "note", "color", "counts", "media", "attribution", "image"].freeze
Class Method Summary collapse
-
.create(data) ⇒ Pinterest::Board
Creates a new pin object.
-
.create_relationships(data) ⇒ Hash
Converts the relationships (user, board, images) of the pin to a gem object.
Instance Method Summary collapse
-
#as_json(options = {}) ⇒ Hash
Serialize the object as a Hash that can be serialized as JSON.
Methods inherited from Entity
Constructor Details
This class inherits a constructor from Pinterest::Entity
Class Method Details
.create(data) ⇒ Pinterest::Board
Creates a new pin object.
18 19 20 21 22 |
# File 'lib/pinterest/models/pin.rb', line 18 def self.create(data) data["created_at"] = Pinterest::Entity.(data["created_at"]) if data["created_at"] data = create_relationships(data) new(data) end |
.create_relationships(data) ⇒ Hash
Converts the relationships (user, board, images) of the pin to a gem object.
28 29 30 31 32 33 |
# File 'lib/pinterest/models/pin.rb', line 28 def self.create_relationships(data) data["creator"] = Pinterest::User.create(data["creator"]) if data["creator"] data["board"] = Pinterest::Board.create(data["board"]) if data["board"] data["image"] = Pinterest::Image.new(data["image"]) if data["image"] data end |