Class: WCC::Blogs::Collection
- Inherits:
-
Object
- Object
- WCC::Blogs::Collection
- Extended by:
- Utils
- Includes:
- WCC::Blogs::Concerns::Caching
- 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
Methods included from WCC::Blogs::Concerns::Caching
#cache_key, #cache_key_with_version, #cache_version
Constructor Details
#initialize(raw, client: WCC::Blogs.client) ⇒ Collection
Returns a new instance of Collection.
16 17 18 19 |
# File 'lib/wcc/blogs/collection.rb', line 16 def initialize(raw, client: WCC::Blogs.client) @raw = raw @client = client end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
14 15 16 |
# File 'lib/wcc/blogs/collection.rb', line 14 def raw @raw end |
Class Method Details
Instance Method Details
#_links ⇒ Object
47 48 49 |
# File 'lib/wcc/blogs/collection.rb', line 47 def _links OpenStruct.new(raw['_links'] || {}) end |
#posts ⇒ Object
40 41 42 43 44 45 |
# File 'lib/wcc/blogs/collection.rb', line 40 def posts @posts ||= (raw['posts'] || []).map do |summary| PostSummary.new(summary, client: @client) end end |
#to_param ⇒ Object
21 22 23 |
# File 'lib/wcc/blogs/collection.rb', line 21 def to_param key end |