Class: Edgar::ModelPermission

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/edgar/model_permission.rb

Overview

Model-wide CRUD permission for role. In other words, CRUD permission for each model for each role is defined by this.

This permission is used for two purposes:

  1. page access permission

    • If this object,which relates to a model by model-attribute, exists and user belongs to the role (= user-group), then the controller, which 'model_class' method returns the model, can be accessed.

  2. popup access permission

    • Popup access for a model-class is an read-permission for that.

Example:

  1. User 'u' belongs to 'x-role' Edgar::UserGroup.

  2. x-role has author model permission.

  3. User 'u' can access AuthorController page.

  4. If x-role has READ permission on author model, then user 'u' can see author-popup on any 'belongs_to' related page (e.g. BookController book form's author-popup).

Defined Under Namespace

Modules: FlagsBitset

Constant Summary

FLAGS_ALL =
FlagsBitset.constants.inject(0){|sum, flag|
  sum += FlagsBitset.const_get(flag)
}

Instance Method Summary (collapse)

Instance Method Details

- (Boolean) permitted?(requested_flags)

return true if ALL requested flags are included in flags

Returns:

  • (Boolean)


37
38
39
# File 'app/models/edgar/model_permission.rb', line 37

def permitted?(requested_flags)
  (self.flags & requested_flags) == requested_flags
end