Class: EacRailsBase0::AppBase::Ability
- Inherits:
-
Object
- Object
- EacRailsBase0::AppBase::Ability
- Includes:
- CanCan::Ability
- Defined in:
- lib/eac_rails_base0/app_base/ability.rb
Direct Known Subclasses
Instance Method Summary collapse
- #administrator_rules(user) ⇒ Object
- #devise_confirmation_rules(user) ⇒ Object
- #devise_invitable_rules(user) ⇒ Object
- #devise_password_rules(user) ⇒ Object
- #devise_registration_rules(user) ⇒ Object
- #devise_rules(user) ⇒ Object
- #devise_session_rules(user) ⇒ Object
-
#initialize(user) ⇒ Ability
constructor
A new instance of Ability.
Constructor Details
#initialize(user) ⇒ Ability
Returns a new instance of Ability.
11 12 13 14 15 16 |
# File 'lib/eac_rails_base0/app_base/ability.rb', line 11 def initialize(user) as_action_aliases user ||= ::EacUsersSupport::User.new devise_rules(user) administrator_rules(user) end |
Instance Method Details
#administrator_rules(user) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/eac_rails_base0/app_base/ability.rb', line 57 def administrator_rules(user) return unless user.administrator? can :manage, ::EacRailsRemotes::Instance can :manage, ::EacUsersSupport::User can :manage, ::Aranha::Address can :manage, ::Aranha::ProcessorConfiguration can :manage, ::Aranha::StartPoint can :manage, ::ScheduledTask can :manage, :eac_rails_base0_mailer end |
#devise_confirmation_rules(user) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/eac_rails_base0/app_base/ability.rb', line 18 def devise_confirmation_rules(user) return unless user.new_record? can :create, 'Devise::Confirmation' can :read, 'Devise::Confirmation' end |
#devise_invitable_rules(user) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/eac_rails_base0/app_base/ability.rb', line 25 def devise_invitable_rules(user) can :create, 'Devise::Invitation' if user.administrator? can :update, 'Devise::Invitation' if user.new_record? can :create, 'DeviseInvitable::Registration' else can :update, 'DeviseInvitable::Registration' end end |
#devise_password_rules(user) ⇒ Object
35 36 37 38 39 |
# File 'lib/eac_rails_base0/app_base/ability.rb', line 35 def devise_password_rules(user) return unless user.new_record? can :manage, 'Devise::Password' end |
#devise_registration_rules(user) ⇒ Object
41 42 43 44 |
# File 'lib/eac_rails_base0/app_base/ability.rb', line 41 def devise_registration_rules(user) can :create, 'Devise::Registration' if user.new_record? can :update, 'Devise::Registration' unless user.new_record? end |
#devise_rules(user) ⇒ Object
51 52 53 54 55 |
# File 'lib/eac_rails_base0/app_base/ability.rb', line 51 def devise_rules(user) %w[confirmation invitable password registration session].each do |devise_module| send("devise_#{devise_module}_rules", user) end end |
#devise_session_rules(user) ⇒ Object
46 47 48 49 |
# File 'lib/eac_rails_base0/app_base/ability.rb', line 46 def devise_session_rules(user) can :destroy, 'Devise::Session' unless user.new_record? can :create, 'Devise::Session' end |