Module: Core::Endpoint::Base::ModelBehaviour

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

Overview

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

Defined Under Namespace

Classes: Handler

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



89
90
91
# File 'app/api/core/endpoint/base.rb', line 89

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

Instance Method Details

#model { ... } ⇒ Void

Opens up a block for defining endpoints on the collection for a given model

Yields:

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

Returns:

  • (Void)


99
100
101
102
# File 'app/api/core/endpoint/base.rb', line 99

def model(&)
  handler = Class.new(Handler).tap { |handler_class| const_set(:Model, handler_class) }.new(&)
  self.model_handler = handler
end