Sha256: ae9e2af73c5e48ec8307c55560e530775553139e6be58d88c9f020635c5ec98e

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

module AppleNews
  class Article
    include Resource
    include Properties

    attr_reader :id

    required_properties :identifier, :title, :layout
    required_property :components, []
    required_property :component_text_styles, {}

    required_property :version, "1.1"
    required_property :language, "en"

    optional_properties :advertising_settings, :subtitle, :metadata, :document_style,
                        :text_styles, :component_layouts, :component_styles

    def initialize(id = nil, opts = nil)
      super(opts)

      @id = id
      @url = "/articles/#{id}"
      @metadata = Metadata.new((opts || {}).fetch(:metadata, {}))

      hydrate! if !id.nil? && opts.nil?
    end

    def persisted?
      !@id.nil?
    end
    alias_method :saved?, :persisted?
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
apple-news-0.1.1 lib/apple-news/article.rb
apple-news-0.1.0 lib/apple-news/article.rb