Sha256: 63a1e4e47b29114136df88eb57dc46c460cbdc9ab71a1973dfa333bf73c3ab02
Contents?: true
Size: 942 Bytes
Versions: 1
Compression:
Stored size: 942 Bytes
Contents
# frozen_string_literal: true module WCC::Blogs class CollectionSummary extend WCC::Blogs::Utils attr_reader :raw def initialize(raw, client: WCC::Blogs.client) @raw = raw @client = client end define_camelcase_alias( 'key', 'title' ) do |camelcase| raw[camelcase] end def posts @posts ||= (raw['posts'] || []).map do |summary| PostReference.new(summary, client: @client) end end class PostReference extend WCC::Blogs::Utils attr_reader :raw def initialize(raw, client: WCC::Blogs.client) @raw = raw @client = client end def full_post Post.new(@client.get(_links.self).raw) end define_camelcase_alias( 'slug' ) do |camelcase| raw[camelcase] end def _links OpenStruct.new(raw['_links'] || {}) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wcc-blogs-client-0.5.2 | lib/wcc/blogs/collection_summary.rb |