Class: Kiita::Post
Constant Summary collapse
- @@attributes =
%w[ id title body created_at updated_at created_at_in_words updated_at_in_words stock_count stock_users comment_count url gist_url private stocked ]
Instance Attribute Summary collapse
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
Class Method Summary collapse
- .all(options = {}) ⇒ Object
- .find(uuid) ⇒ Object
- .lazy_load(uuid) ⇒ Object
- .search(keyword, options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(uuid, options = {}) ⇒ Post
constructor
A new instance of Post.
Methods included from Model
Constructor Details
#initialize(uuid, options = {}) ⇒ Post
Returns a new instance of Post.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/kiita/post.rb', line 14 def initialize(uuid, = {}) if uuid.is_a?(Hash) = uuid @uuid = ["uuid"] else @uuid = uuid end super() end |
Instance Attribute Details
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
4 5 6 |
# File 'lib/kiita/post.rb', line 4 def uuid @uuid end |
Class Method Details
.all(options = {}) ⇒ Object
25 26 27 |
# File 'lib/kiita/post.rb', line 25 def self.all( = {}) Kiita::API.get("/items", ).map{|post| Kiita::Post.new(post) } end |
.find(uuid) ⇒ Object
37 38 39 |
# File 'lib/kiita/post.rb', line 37 def self.find(uuid) new(uuid, Kiita::API.get("/items/#{uuid}").merge!(loaded: true)) end |
.lazy_load(uuid) ⇒ Object
33 34 35 |
# File 'lib/kiita/post.rb', line 33 def self.lazy_load(uuid) new(uuid) end |