Sha256: 1dd1192f37673475a3c22dd79f6c8d109354e6563b586c42765dd325219083e8

Contents?: true

Size: 814 Bytes

Versions: 23

Compression:

Stored size: 814 Bytes

Contents

require 'api_resource/associations/scope'

module ApiResource
  
  module Associations
    
    class ResourceScope < Scope
      
      include Enumerable

      def internal_object
        @internal_object ||= self.klass.send(:find, :all, :params => self.to_hash)
      end
      
      alias_method :all, :internal_object
      
      def each(*args, &block)
        self.internal_object.each(*args, &block)
      end
      
      # get the relevant class
      def self.class_factory(hsh)
        case hsh.values.first
          when TrueClass, FalseClass
            ApiResource::Associations::ResourceScope
          when Array
            ApiResource::Associations::MultiArgumentResourceScope
          else
            ApiResource::Associations::DynamicResourceScope
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
api_resource-0.3.12 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.11 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.10 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.8 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.7 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.6 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.5 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.4 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.3 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.2 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.1 lib/api_resource/associations/resource_scope.rb
api_resource-0.3.0 lib/api_resource/associations/resource_scope.rb
api_resource-0.2.11 lib/api_resource/associations/resource_scope.rb
api_resource-0.2.10 lib/api_resource/associations/resource_scope.rb
api_resource-0.2.9 lib/api_resource/associations/resource_scope.rb
api_resource-0.2.8 lib/api_resource/associations/resource_scope.rb
api_resource-0.2.7 lib/api_resource/associations/resource_scope.rb
api_resource-0.2.6 lib/api_resource/associations/resource_scope.rb
api_resource-0.2.5 lib/api_resource/associations/resource_scope.rb
api_resource-0.2.4 lib/api_resource/associations/resource_scope.rb