Module: Core::Endpoint::BasicHandler::Handlers

Included in:
Core::Endpoint::BasicHandler
Defined in:
app/api/core/endpoint/basic_handler/handlers.rb

Constant Summary collapse

NullHandler =

Handler that behaves like it never deals with any URLs

Object.new.tap do |handler|
  [:create, :read, :update, :delete].each do |action|
    handler.define_singleton_method(action) do |*_args|
      raise ::Core::Service::UnsupportedAction
    end
  end
end

Instance Method Summary collapse

Instance Method Details

#actions(object, options) ⇒ Object


20
21
22
23
24
25
26
27
28
# File 'app/api/core/endpoint/basic_handler/handlers.rb', line 20

def actions(object, options)
  @handlers.select do |_name, handler|
    handler.is_a?(Core::Endpoint::BasicHandler::Actions::InnerAction)
  end.map do |_name, handler|
    handler.send(:actions, object, options)
  end.inject(super) do |actions, subactions|
    actions.merge(subactions)
  end
end

#initializeObject


11
12
13
14
# File 'app/api/core/endpoint/basic_handler/handlers.rb', line 11

def initialize
  super
  @handlers = {}
end

16
17
18
# File 'app/api/core/endpoint/basic_handler/handlers.rb', line 16

def related
  @handlers.map(&:last)
end