Sha256: ed53b33940e5bc49ba6fa2e3d7302fafcb03a744d32a5cdaac4d9f73c98f0630

Contents?: true

Size: 754 Bytes

Versions: 11

Compression:

Stored size: 754 Bytes

Contents

module Resourcelogic
  module Scope
    def self.included(klass)
      klass.class_eval do
        add_acts_as_resource_module(Methods)
      end
    end
    
    module Methods
      def self.included(klass)
        klass.class_eval do
          attr_accessor :scoping, :scoping_parent
        end
      end
      
      private
        def scope
          return @scope if defined?(@scope)
          
          if parent?
            @scope = parent_object.send(parent_scope_name)
          else
            @scope = model
          end
        end
        
        def parent_scope
          parent_model
        end
        
        def parent_scope_name
          @parent_scope_name ||= model_name.to_s.pluralize
        end
    end
  end
end       

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
binarylogic-resourcelogic-0.0.11 lib/resourcelogic/scope.rb
binarylogic-resourcelogic-0.0.12 lib/resourcelogic/scope.rb
binarylogic-resourcelogic-0.12.0 lib/resourcelogic/scope.rb
binarylogic-resourcelogic-0.12.1 lib/resourcelogic/scope.rb
binarylogic-resourcelogic-0.12.2 lib/resourcelogic/scope.rb
resourcelogic-0.0.11 lib/resourcelogic/scope.rb
resourcelogic-0.0.12 lib/resourcelogic/scope.rb
resourcelogic-0.12.0 lib/resourcelogic/scope.rb
resourcelogic-0.12.1 lib/resourcelogic/scope.rb
resourcelogic-0.12.2 lib/resourcelogic/scope.rb
resourcelogic-0.11.0 lib/resourcelogic/scope.rb