module ACTV::Authorable

Public Instance Methods

author() click to toggle source
# File lib/actv/authorable.rb, line 4
def author
  @author ||= author_from_reference || author_from_article
end
author_name_from_by_line() click to toggle source
# File lib/actv/authorable.rb, line 12
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
by_line() click to toggle source
# File lib/actv/authorable.rb, line 8
def by_line
  @by_line ||= description_by_type 'articleByLine'
end

Private Instance Methods

author_from_article() click to toggle source
# File lib/actv/authorable.rb, line 19
def author_from_article
  ACTV::Author.build_from_article self.to_hash
end
author_from_reference() click to toggle source
# File lib/actv/authorable.rb, line 23
def author_from_reference
  if author_reference
    ACTV.asset(author_reference.id).first
  end
rescue ACTV::Error::NotFound
  nil
end
author_reference() click to toggle source
# File lib/actv/authorable.rb, line 31
def author_reference
  references.find { |reference| reference.type == "author" }
end