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

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

Instance Method Summary collapse

Instance Method Details

#for_jsonObject



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

def for_json
  nil
end

#generate_json_actions(object, options) ⇒ Object



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

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

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

Raises:

  • (StandardError)


3
4
5
6
7
8
9
10
11
# 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() do # prettier-ignore
  end

  @options, @handler = options, block
  action(name, options)
end

#separate(_, actions) ⇒ Object



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

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