Sha256: 19071782705aac06e0fa0598e0d035dd64dc68e15ca55927b7c1f274d8b4bed6

Contents?: true

Size: 662 Bytes

Versions: 28

Compression:

Stored size: 662 Bytes

Contents

require 'api_resource/associations/resource_scope'

module ApiResource
  module Associations
    class DynamicResourceScope < ResourceScope
      
      attr_accessor :dynamic_value
      # initializer - set up the dynamic value
      def initialize(klass, current_scope, dynamic_value, opts = {})
        self.dynamic_value = dynamic_value
        super(klass, current_scope, opts)
      end
      # get the to_query value for this resource scope
      def to_hash
        hsh = self.scopes[self.current_scope].clone
        hsh.each_pair do |k,v|
          hsh[k] = self.dynamic_value
        end
        self.parent_hash.merge(hsh)
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
api_resource-0.4.3 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.4.2 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.4.0 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.14 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.13 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.12 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.11 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.10 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.8 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.7 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.6 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.5 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.4 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.3 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.2 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.1 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.3.0 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.2.11 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.2.10 lib/api_resource/associations/dynamic_resource_scope.rb
api_resource-0.2.9 lib/api_resource/associations/dynamic_resource_scope.rb