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, &block) ⇒ Object


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

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


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

def initialize
  super
  @endpoints = []
end

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

def related
  super.concat(@endpoints)
end