Sha256: 75bdee15f05123ad1eab971cdb4f95b27104b195aba340e2707053b59ad12a2f

Contents?: true

Size: 479 Bytes

Versions: 1

Compression:

Stored size: 479 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

1 entries across 1 versions & 1 rubygems

Version Path
abilities-0.1.1 lib/abilities/proxy.rb