Sha256: 9af8f247dc0b5634616f3f0f825ba232b58d10ab4a054ba9686518d63bdc48dc

Contents?: true

Size: 509 Bytes

Versions: 3

Compression:

Stored size: 509 Bytes

Contents

module PrivatePerson
  module Permissible
    def acts_as_permissible(params = {})
      if params[:by].nil?
        raise 'Called acts_as_permissible, but without a :by parameter.'
      end
      class_attribute :by
      self.by = params[:by]

      class_eval do
        has_many :permissions, :as => :permissible
        has_one :permissor, :through => :permissions, :as => :permissor

        def is_public?
          !permissions.by_relationship_type(nil).empty?
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
private_person-0.3.1 lib/private_person/models/permissible.rb
private_person-0.3.0 lib/private_person/models/permissible.rb
private_person-0.2.9 lib/private_person/models/permissible.rb