Sha256: dd24e1f53fcbf22090ce5393d7a8d42e46ba133d418e3d633ed294f10fe7f832
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
module Recurso class Config include Singleton DEFAULT_IDENTITY_FOREIGN_KEY = :identity_id DEFAULT_PERMISSION_CLASS_NAME = 'Permission' attr_accessor :levels_for_action, :actions_for_default, :levels, :default_level, :identity_foreign_key, :permission_class_name, :default_permission_class_name def initialize @levels_for_action = { view: [:admin, :editor, :viewer], modify: [:admin, :editor], administer: [:admin], } @actions_for_default = { open: [:view, :modify], closed: [:view], secret: [], } @levels = [:member, :admin, :editor, :viewer] @default_level = :member @identity_foreign_key = DEFAULT_IDENTITY_FOREIGN_KEY @permission_class_name = DEFAULT_PERMISSION_CLASS_NAME end def model_specific(value, model) if value.respond_to?(:call) value.call(model) else value end end def identity_foreign_key_for(model) model_specific(identity_foreign_key, model) || DEFAULT_IDENTITY_FOREIGN_KEY end def permission_class_name_for(identity_model) model_specific(permission_class_name, identity_model) || DEFAULT_PERMISSION_CLASS_NAME end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
recurso-0.5.3 | lib/recurso/config.rb |