Sha256: cd2c7f8940b00c7d4de9a719a9f417528606e76d7402b9d16e5a9c286a48f367

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

# == Schema Information
#
# Table name: underworld_permissions
#
#  id              :integer          not null, primary key
#  model           :string
#  permission_type :string
#  created_at      :datetime
#  updated_at      :datetime
#

module Underworld
  class Permission < ORM.proper_base_class

    if ::Underworld::ORM.mongoid?
      include Mongoid::Document
      include Mongoid::Timestamps

      field :model, type: String
      field :permission_type, type: String

    end

    has_and_belongs_to_many :groups, class_name: 'Underworld::Group'
    alias_attribute :action, :permission_type

    #alias_method :action, :permission_type

    def to_s
      t('permission_string', action: t(self.permission_type.to_s),
        model: t(self.model.underscore.humanize))
    end

    def id_repr
      "#{self.permission_type.to_s}|#{self.model}"
    end

    def model_name
      model.underscore.humanize
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
underworld-1.0.0 app/models/underworld/permission.rb