Sha256: fc0612ac77594c80f3af752ce79f1e4ce3c015b155b1fa95526f80877bd512c6

Contents?: true

Size: 731 Bytes

Versions: 17

Compression:

Stored size: 731 Bytes

Contents

module ACTV
  module Authorable

    def author
      @author ||= author_from_reference || author_from_article
    end

    def by_line
      @by_line ||= description_by_type 'articleByLine'
    end

    def author_name_from_by_line
      author_name_regex = /by (.*)/i.match by_line
      author_name_regex[1].strip if author_name_regex.present?
    end

    private

    def author_from_article
      ACTV::Author.build_from_article self.to_hash
    end

    def author_from_reference
      if author_reference
        ACTV.asset(author_reference.id).first
      end
    rescue ACTV::Error::NotFound
      nil
    end

    def author_reference
      references.find { |reference| reference.type == "author" }
    end
  end
end


Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
actv-2.10.9 lib/actv/authorable.rb
actv-2.10.8 lib/actv/authorable.rb
actv-2.10.7 lib/actv/authorable.rb
actv-2.10.6 lib/actv/authorable.rb
actv-2.10.5 lib/actv/authorable.rb
actv-2.10.4 lib/actv/authorable.rb
actv-2.10.3 lib/actv/authorable.rb
actv-2.10.2 lib/actv/authorable.rb
actv-2.10.1 lib/actv/authorable.rb
actv-2.10.0 lib/actv/authorable.rb
actv-2.9.2 lib/actv/authorable.rb
actv-2.9.1 lib/actv/authorable.rb
actv-2.9.0 lib/actv/authorable.rb
actv-2.8.2 lib/actv/authorable.rb
actv-2.8.1 lib/actv/authorable.rb
actv-2.7.0 lib/actv/authorable.rb
actv-2.6.0 lib/actv/authorable.rb