Sha256: fbdeb3d28a29594d3be0c5a7adf4b12ba20166d3a4c19a935354fb1deb91afe5
Contents?: true
Size: 750 Bytes
Versions: 2
Compression:
Stored size: 750 Bytes
Contents
# frozen_string_literal: true module WCC::Blogs class Collection extend WCC::Blogs::Utils def self.find(key = nil) new(WCC::Blogs.client.collection_show(key).raw, client: WCC::Blogs.client) end attr_reader :raw def initialize(raw, client: WCC::Blogs.client) @raw = raw @client = client end def to_param key end define_camelcase_alias( 'key', 'title', 'digest' ) do |camelcase| raw[camelcase] end def posts @posts ||= (raw['posts'] || []).map do |summary| PostSummary.new(summary, client: @client) end end def _links OpenStruct.new(raw['_links'] || {}) end alias cache_key digest end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wcc-blogs-client-0.6.0 | lib/wcc/blogs/collection.rb |
wcc-blogs-client-0.5.2 | lib/wcc/blogs/collection.rb |