Module: Core::Endpoint::BasicHandler::Associations::BelongsTo

Included in:
Core::Endpoint::BasicHandler
Defined in:
app/api/core/endpoint/basic_handler/associations/belongs_to.rb

Overview

rubocop:todo Style/Documentation

Defined Under Namespace

Classes: Handler

Instance Method Summary collapse

Instance Method Details

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


63
64
65
66
# File 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb', line 63

def belongs_to(name, options, &block)
  class_handler = Class.new(Handler).tap { |handler| self.class.const_set(name.to_s.camelize, handler) }
  @endpoints.push(class_handler.new(name, options, &block))
end

#initializeObject


58
59
60
61
# File 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb', line 58

def initialize
  super
  @endpoints = []
end

68
69
70
# File 'app/api/core/endpoint/basic_handler/associations/belongs_to.rb', line 68

def related
  super.concat(@endpoints)
end