Module: Core::Endpoint::Base::InstanceBehaviour

Included in:
Core::Endpoint::Base
Defined in:
app/api/core/endpoint/base.rb

Overview

Adds ability to define instance endpoints to Core::Endpoint::Base

Defined Under Namespace

Classes: Handler

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



50
51
52
# File 'app/api/core/endpoint/base.rb', line 50

def self.extended(base)
  base.class_attribute :instance_handler, instance_writer: false
end

Instance Method Details

#instance { ... } ⇒ Void

Opens up a block for defining endpoints on an instance of the model

Yields:

  • [] Yields control to block evaluated by the InstanceBehaviour::Handler This is where you define your actions.

Returns:

  • (Void)


60
61
62
63
64
# File 'app/api/core/endpoint/base.rb', line 60

def instance(&)
  handler = Class.new(Handler).tap { |handler_class| const_set(:Instance, handler_class) }.new(&)
  handler.instance_variable_set(:@name, name)
  self.instance_handler = handler
end