class HALPresenter::Collection::Properties

Attributes

name[R]
scope[R]

Public Class Methods

new(name, scope, &block) click to toggle source
# File lib/hal_presenter/collection.rb, line 16
def initialize(name, scope, &block)
  @name = name
  return unless block_given?
  @scope = scope
  instance_exec(&block)
end

Public Instance Methods

attribute(*args, **kwargs, &block) click to toggle source
Calls superclass method HALPresenter::Attributes#attribute
# File lib/hal_presenter/collection.rb, line 23
def attribute(*args, **kwargs, &block)
  kwargs[:context] = scope
  super
end
change_context(context) click to toggle source
# File lib/hal_presenter/collection.rb, line 43
def change_context(context)
  @scope = context
  self
end
curie(rel, value = nil, **kwargs, &block) click to toggle source
Calls superclass method HALPresenter::Curies#curie
# File lib/hal_presenter/collection.rb, line 33
def curie(rel, value = nil, **kwargs, &block)
  kwargs[:context] = scope
  super
end
embed(*args, **kwargs, &block) click to toggle source
Calls superclass method HALPresenter::Embedded#embed
# File lib/hal_presenter/collection.rb, line 38
def embed(*args, **kwargs, &block)
  kwargs[:context] = scope
  super
end

Private Instance Methods

method_missing(method, *args, &block) click to toggle source
Calls superclass method
# File lib/hal_presenter/collection.rb, line 50
def method_missing(method, *args, &block)
  return super unless scope&.respond_to? method
  define_singleton_method(method) { |*a, &b| scope.public_send method, *a, &b }
  public_send(method, *args, &block)
end
respond_to_missing?(method, include_private = false) click to toggle source
Calls superclass method
# File lib/hal_presenter/collection.rb, line 56
def respond_to_missing?(method, include_private = false)
  return true if scope&.respond_to? method
  super
end