Class: ActiveRecord::Base::Permissions
- Inherits:
-
Object
- Object
- ActiveRecord::Base::Permissions
- Defined in:
- lib/red_base/active_record.rb
Constant Summary collapse
- @@permissions =
{ :read => nil, :update => nil, :create => nil, :destory => nil, }
- @@only_owner =
false
Class Method Summary collapse
-
.only_his_objects ⇒ Object
This force user to have access to resources which is his.
- .only_his_objects? ⇒ Boolean
-
.permission_strings(model) ⇒ Object
return an array of strings representation of permissions.
-
.permissions(*args) ⇒ Object
Define permissions using this method.
Class Method Details
.only_his_objects ⇒ Object
This force user to have access to resources which is his.
68 69 70 |
# File 'lib/red_base/active_record.rb', line 68 def self.only_his_objects @@only_owner = true end |
.only_his_objects? ⇒ Boolean
72 73 74 |
# File 'lib/red_base/active_record.rb', line 72 def self.only_his_objects? @@only_owner end |
.permission_strings(model) ⇒ Object
return an array of strings representation of permissions
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/red_base/active_record.rb', line 34 def self.(model) strings = [] @@permissions.each do |key, value| strings << { :name => "#{key}|#{model.model_name}", :string => _("can %s %s") % [_(key.to_s), model.model_name.human] } end strings end |
.permissions(*args) ⇒ Object
Define permissions using this method
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/red_base/active_record.rb', line 47 def self.(*args) args.each do || if .class == Symbol if not @@permissions.include? @@permission[] = nil elsif .class == Hash .each do |key, value| @@permissions[key.to_sym] = value end end end end end |