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

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

Defined Under Namespace

Classes: Handler

Instance Method Summary collapse

Instance Method Details

#belongs_to(name, options) ⇒ Object



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

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

#initializeObject



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

def initialize
  super
  @endpoints = []
end


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

def related
  super.concat(@endpoints)
end