Class: WCC::Blogs::Collection
- Inherits:
-
Object
- Object
- WCC::Blogs::Collection
- Extended by:
- Utils
- Defined in:
- lib/wcc/blogs/collection.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Class Method Summary collapse
Instance Method Summary collapse
- #_links ⇒ Object
-
#initialize(raw, client: WCC::Blogs.client) ⇒ Collection
constructor
A new instance of Collection.
- #posts ⇒ Object
- #to_param ⇒ Object
Methods included from Utils
camelcase, define_camelcase_alias
Constructor Details
#initialize(raw, client: WCC::Blogs.client) ⇒ Collection
Returns a new instance of Collection.
13 14 15 16 |
# File 'lib/wcc/blogs/collection.rb', line 13 def initialize(raw, client: WCC::Blogs.client) @raw = raw @client = client end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
11 12 13 |
# File 'lib/wcc/blogs/collection.rb', line 11 def raw @raw end |
Class Method Details
Instance Method Details
#_links ⇒ Object
44 45 46 |
# File 'lib/wcc/blogs/collection.rb', line 44 def _links OpenStruct.new(raw['_links'] || {}) end |
#posts ⇒ Object
37 38 39 40 41 42 |
# File 'lib/wcc/blogs/collection.rb', line 37 def posts @posts ||= (raw['posts'] || []).map do |summary| PostSummary.new(summary, client: @client) end end |
#to_param ⇒ Object
18 19 20 |
# File 'lib/wcc/blogs/collection.rb', line 18 def to_param key end |