Class: Core::Endpoint::BasicHandler::Associations::BelongsTo::Handler::Association

Inherits:
Object
  • Object
show all
Includes:
Io::Json::Grammar::Intermediate, Io::Json::Grammar::Resource
Defined in:
app/api/core/endpoint/basic_handler/associations/belongs_to.rb

Instance Method Summary collapse

Constructor Details

#initialize(endpoint_helper, children = nil) ⇒ Association


27
28
29
30
# File 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb', line 27

def initialize(endpoint_helper, children = nil)
  super(children)
  @endpoint_helper = endpoint_helper
end

Instance Method Details

#actions(*args) ⇒ Object


47
48
49
# File 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb', line 47

def actions(*args)
  # Nothing needed here!
end

#call(object, options, stream) ⇒ Object


38
39
40
41
42
43
44
45
# File 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb', line 38

def call(object, options, stream)
  @endpoint_helper.call(object) do |json_root, endpoint, associated_object|
    stream.block(json_root) do |nested_stream|
      resource_details(endpoint.instance_handler, associated_object, options, stream)
      super(object, options, nested_stream)
    end
  end
end

#merge(node) ⇒ Object


34
35
36
# File 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb', line 34

def merge(node)
  super(node) { |children| self.class.new(@endpoint_helper, children) }
end