Sha256: dae6f5e2cdb4fadc6f90e1cde7a5d1d7c52228620ac61f6720b0434d0622a4ed
Contents?: true
Size: 926 Bytes
Versions: 5
Compression:
Stored size: 926 Bytes
Contents
module NinjaModel module Associations class HasManyAssociation def initialize(owner, reflection) @owner, @reflection = owner, reflection @relation = reflection.klass.scoped.where(reflection.primary_key_name.to_sym.eq(owner.id)) end delegate :each, :collect, :map, :to_a, :size, :blank?, :empty?, :to => :relation def method_missing(method, *args) if @relation.respond_to?(method) @relation.send(method, *args) elsif @relation.klass.respond_to?(method) @relation.klass.send(method, *args) else super end end def relation @relation end def inspect @relation.to_a.inspect end def replace(other_array) @current = other_array end def blank? @relation.blank? end def to_ary @relation.to_a end end end end
Version data entries
5 entries across 5 versions & 1 rubygems