module Libis::Ingester::API::Representer::Base

Public Class Methods

included(klass) click to toggle source
# File lib/libis/ingester/server/api/representer/base.rb, line 34
def self.included(klass)
  klass.class_eval do

    include Roar::JSON
    include Roar::Coercion
    include Representable::Hash
    include Representable::Hash::AllowSymbols
    include Roar::JSON::JSONAPI::Mixin
    extend Pagination

    property :id, exec_context: :decorator, writable: false,
             type: String, desc: 'Object\'s unique identifier'

    attributes do
      property :c_at, as: :created_at, writeable: false, type: DateTime, desc: 'Date when the object was created'
    end
    link(:self) do |opts|
      "#{self_url(opts)}/#{represented.id}"
    end

    link(:self, toplevel: true) do |opts|
      opts[:this_url]
    end

    def id
      represented.id.to_s
    end

    def id=(_value)
      # do nothing
    end

  end
end

Public Instance Methods

id() click to toggle source
# File lib/libis/ingester/server/api/representer/base.rb, line 58
def id
  represented.id.to_s
end
id=(_value) click to toggle source
# File lib/libis/ingester/server/api/representer/base.rb, line 62
def id=(_value)
  # do nothing
end
self_url(opts) click to toggle source
# File lib/libis/ingester/server/api/representer/base.rb, line 22
def self_url(opts)
  self.class.self_url(opts)
end