Module: Core::Endpoint::BasicHandler::Actions::InnerAction

Included in:
Bound::Handler
Defined in:
app/api/core/endpoint/basic_handler/actions/inner_action.rb

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Instance Method Details

#for_jsonObject


18
19
20
# File 'app/api/core/endpoint/basic_handler/actions/inner_action.rb', line 18

def for_json
  nil
end

#generate_json_actions(object, options) ⇒ Object


29
30
31
# File 'app/api/core/endpoint/basic_handler/actions/inner_action.rb', line 29

def generate_json_actions(object, options)
  rooted_json(options) { |stream| super(object, options.merge(stream: stream)) }
end

#initialize(name, options, &block) ⇒ Object

Raises:

  • (StandardError)

3
4
5
6
7
8
9
# File 'app/api/core/endpoint/basic_handler/actions/inner_action.rb', line 3

def initialize(name, options, &block)
  raise StandardError, "Cannot declare inner action #{name.inspect} without a block" unless block

  super() {}
  @options, @handler = options, block
  action(name, options)
end

#separate(_, actions) ⇒ Object


11
12
13
14
15
16
# File 'app/api/core/endpoint/basic_handler/actions/inner_action.rb', line 11

def separate(_, actions)
  actions[@options[:to].to_s] =
    lambda do |object, options, stream|
      actions(object, options.merge(target: object)).map { |action, url| stream.attribute(action, url) }
    end
end