Class: Core::Endpoint::BasicHandler::Actions::Factory::Nested

Inherits:
Core::Endpoint::BasicHandler
  • Object
show all
Defined in:
app/api/core/endpoint/basic_handler/actions/factory.rb

Overview

rubocop:todo Style/Documentation

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Nested

Returns a new instance of Nested.


4
5
6
7
# File 'app/api/core/endpoint/basic_handler/actions/factory.rb', line 4

def initialize(name, &block)
  super(&block)
  @name = name.to_s
end

Instance Method Details

#core_path(*args) ⇒ Object


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

def core_path(*args)
  super(@name, *args)
end

#separate(associations, _) ⇒ Object


9
10
11
12
13
14
15
16
17
18
# File 'app/api/core/endpoint/basic_handler/actions/factory.rb', line 9

def separate(associations, _)
  associations[@name] =
    lambda do |object, options, stream|
      stream.block(@name) do |nested_stream|
        nested_stream.block('actions') do |action_stream|
          actions(object, options.merge(target: object)).map { |action, url| action_stream.attribute(action, url) }
        end
      end
    end
end