Sha256: 25b5927f742f53e5dd2d9769647f35257f6d659e331ab71b801e102e28e108a6
Contents?: true
Size: 1.04 KB
Versions: 5
Compression:
Stored size: 1.04 KB
Contents
require 'apple-news/article/attachments' require 'apple-news/article/persistence' module AppleNews class Article extend Forwardable include Attachments include Persistence include Resource include Properties optional_properties :is_sponsored, :is_preview, :accessory_text, :revision optional_property :links, {} attr_reader :id attr_accessor :document def_delegator :@document, :title def initialize(id = nil, data = {}) super(data) @resource_path = "/articles" @id = id document = (data[:document] || data['document']) @document = document.is_a?(AppleNews::Document) ? document : Document.new(document) @files = {} # These are read-only properties that are not submitted to the API @share_url = data['shareUrl'] @state = data['state'] hydrate! if !id.nil? && data.keys.size == 0 end private def hydrate! data = fetch_data['data'] @document = Document.new(data.delete('document')) load_properties(data) end end end
Version data entries
5 entries across 5 versions & 1 rubygems