Sha256: a041c536710031a07ebdcffb7d7a20e9b92714e5c4f16317fc30731eed3ef28f

Contents?: true

Size: 480 Bytes

Versions: 6

Compression:

Stored size: 480 Bytes

Contents

module Abilities
  class Proxy

    def initialize(actor, definitions, &block)
      @actor = actor
      @definitions = definitions
      instance_eval &block
    end

    def can(actions, subjects, &block)
      @definitions.add actions, subjects, true, &block
    end

    def cannot(actions, subjects, &block)
      @definitions.add actions, subjects, false, &block
    end

    def method_missing(name, *args, &block)
      @actor.send name, *args, &block
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
abilities-0.1.2 lib/abilities/proxy.rb
abilities-0.1.0 lib/abilities/proxy.rb
abilities-0.0.4 lib/abilities/proxy.rb
abilities-0.0.3 lib/abilities/proxy.rb
abilities-0.0.2 lib/abilities/proxy.rb
abilities-0.0.1 lib/abilities/proxy.rb