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

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Nested

Returns a new instance of Nested


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

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


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

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 do |action, url|
          action_stream.attribute(action, url)
        end
      end
    end
  end
end