Module: Utusemi::Core::ActiveRecord::Associations

Defined in:
lib/utusemi/core.rb

Overview

用途

関連モデルにカラムマッパを継承する

使用例

class Product
  has_many :stocks
  ...
end
stock = Product.utusemi(:product).stocks.first
stock.quantity
#=> 10 (= stocks.units)

Instance Method Summary collapse

Instance Method Details

#load_target(*args) ⇒ Object



340
341
342
343
344
# File 'lib/utusemi/core.rb', line 340

def load_target(*args)
  utusemi_values = truthly_owner.utusemi_values
  return super unless utusemi_values[:flag]
  super.each { |record| record.utusemi!(@reflection.klass.model_name.singular, utusemi_values[:options]) }
end

#scope(*args) ⇒ Object



334
335
336
337
338
# File 'lib/utusemi/core.rb', line 334

def scope(*args)
  utusemi_values = truthly_owner.utusemi_values
  return super unless utusemi_values[:flag]
  super.utusemi!(@reflection.klass.model_name.singular, utusemi_values[:options])
end