Sha256: e94e21a5d2124d82e5ae1860f238939157d08442ba89951f3e7ba0e4ada8823c

Contents?: true

Size: 717 Bytes

Versions: 5

Compression:

Stored size: 717 Bytes

Contents

# frozen_string_literal: true

module DateBook
  # DateBook Ability model
  module Ability
    include CanCan::Ability

    def initialize_date_book(user)
      alias_action :index, :show, :popover, to: :read
      if user.has_role? :admin
        can :manage, :all
      elsif user.new_record?
        can :read, Calendar
        can :read, Event
      else
        can :read, Calendar
        can :create, Calendar
        can :manage, Calendar, id: Calendar.with_role(:owner, user).ids

        can :read, Event
        cannot :create, Event
        can :manage, Event, calendar_id: Calendar.with_role(:owner, user).ids
        can :manage, Event, id: Event.with_role(:owner, user).ids
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
date_book-0.0.6 lib/date_book/concerns/ability.rb
date_book-0.0.5 lib/date_book/concerns/ability.rb
date_book-0.0.3 lib/date_book/concerns/ability.rb
date_book-0.0.2 lib/date_book/concerns/ability.rb
date_book-0.0.1 lib/date_book/concerns/ability.rb