Sha256: 6b0b1ac58bc9205ece300bced495c1a6ab9b1b9d773d38a4b79bb11c447e66c4

Contents?: true

Size: 1.36 KB

Versions: 22

Compression:

Stored size: 1.36 KB

Contents

require 'cutter'
Cutter::Stamper.scope :ability => "Ability#initialize" do |stan|
  stan.msg :no_cache          => 'No caching, going through engines'
  stan.msg :permissions_done  => "Permissions finished"
  stan.msg :permits_done      => "Permits finished"
  stan.msg :caching_done      => "Caching finished"
end

module CanTango
  class PerformanceTestAbility < CanTango::Ability
    def initialize candidate, options = {}

      raise "Candidate must be something!" if !candidate
      @candidate, @options = candidate, options
      @session = options[:session] || {} # seperate session cache for each type of user?

      if cached_rules?
        @rules_cached = true
        puts "Using Cache..."
        return
      end

      stamper(:ability) {
        raise "Candidate must be something!" if !candidate
        @candidate, @options = candidate, options
        @session = options[:session] || {} # seperate session cache for each type of user?
      }

      stamper(:ability) do |st| 
        st.stamp(:no_cache)
        with(:permissions)  {|permission| permission.evaluate! user }
        st.stamp :permissions_done

        with(:permits)      {|permit| break if permit.execute == :break }
        st.stamp :permits_done

        cache_rules!
        st.stamp :caching_done
      end
    end
  end
end

CanTango.config.ability.default_class = CanTango::PerformanceTestAbility

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cantango-0.9.4.7 spec/integration/performance/helpers/ability.rb
cantango-0.9.4.6 spec/integration/performance/helpers/ability.rb
cantango-0.9.4.5 spec/integration/performance/helpers/ability.rb
cantango-0.9.4.3 spec/integration/performance/helpers/ability.rb
cantango-0.9.4.2 spec/integration/performance/helpers/ability.rb
cantango-0.9.4.1 spec/integration/performance/helpers/ability.rb
cantango-0.9.4 spec/integration/performance/helpers/ability.rb
cantango-0.9.3.2 spec/integration/performance/helpers/ability.rb
cantango-0.8.9.5 spec/integration/performance/helpers/ability.rb
cantango-0.8.9.4 spec/integration/performance/helpers/ability.rb
cantango-0.8.9.3 spec/integration/performance/helpers/ability.rb
cantango-0.8.9.2 spec/integration/performance/helpers/ability.rb
cantango-0.8.9.1 spec/integration/performance/helpers/ability.rb
cantango-0.8.9 spec/integration/performance/helpers/ability.rb
cantango-0.8.8.1 spec/integration/performance/helpers/ability.rb
cantango-0.8.8 spec/integration/performance/helpers/ability.rb
cantango-0.8.7 spec/integration/performance/helpers/ability.rb
cantango-0.8.6.2 spec/integration/performance/helpers/ability.rb
cantango-0.8.6.1 spec/integration/performance/helpers/ability.rb
cantango-0.8.6 spec/integration/performance/helpers/ability.rb