lib/ninja_model/relation.rb in ninja-model-0.6.2 vs lib/ninja_model/relation.rb in ninja-model-0.7.0

- old
+ new

@@ -9,19 +9,22 @@ delegate :length, :each, :map, :collect, :all?, :include?, :to => :to_a attr_reader :klass, :loaded attr_accessor :ordering, :predicates, :limit_value, :offset_value + attr_accessor :default_scoped + alias :default_scoped? :default_scoped alias :loaded? :loaded SINGLE_VALUE_ATTRS = [:limit, :offset] MULTI_VALUE_ATTRS = [:ordering, :predicates] def initialize(klass) @klass = klass @loaded = false + @default_scoped = false SINGLE_VALUE_ATTRS.each do |v| instance_variable_set("@#{v}_value".to_sym, nil) end @@ -85,11 +88,11 @@ protected def method_missing(method, *args, &block) if Array.method_defined?(method) to_a.send(method, *args, &block) - elsif @klass.scopes[method] - merge(@klass.send(method, *args, &block)) + elsif @klass.singleton_class.respond_to?(method) + merge(@klass.singleton_class.send(method, *args, &block)) elsif @klass.respond_to?(method) scoping { @klass.send(method, *args, &block) } else super end