Sha256: 9aa942b4ebbd8b0c045a0f1e4346d6fa20983400d1aa8640eb20536133d11a58

Contents?: true

Size: 894 Bytes

Versions: 3

Compression:

Stored size: 894 Bytes

Contents

module Pbw
  class Capability < Rule
    has_and_belongs_to_many :tokens

    def self.viewable_by?(user, subject)
        return true if user.admin?
        subject.tokens.each do |token|
            return true token.user && token.user == user
        end
        false
    end

    def self.creatable_by?(user, subject)
        user.admin?
    end

    def self.editable_by?(user, subject)
        user.admin?
    end

    def self.deletable_by?(user, subject)
        user.admin?
    end

    def before_process(token, &changeset)
    	# stub method
    	true
    end

    def before_add(token)
    	# stub method
    	true
    end

    def after_add(token)
    	# stub method
    end

    def before_remove(token)
    	# stub method
    	true
    end

    def after_remove(token)
    	# stub method
    end

    def can_convert?(item)
        # stub method
        false
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pbw-0.0.9 app/models/pbw/capability.rb
pbw-0.0.8 app/models/pbw/capability.rb
pbw-0.0.7 app/models/pbw/capability.rb