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) ⇒ 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, &)
  super(&)
  @name = name.to_s
end

Instance Method Details

#core_pathObject



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

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

#separate(associations, _) ⇒ Object



9
10
11
12
13
14
15
16
17
# 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