Sha256: 1674a9d0c972e3eb9f17692c730ea022298d5ba7ade6d536054655d50777cf7f

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

class Ishapi::Ability
  include ::CanCan::Ability

  def initialize user

    #
    # signed in user
    #
    unless user.blank?

      if user.profile && user.profile.sudoer?
        can :manage, :all
      end

      can [ :show ], Gallery do |gallery|
        gallery.user == user
      end

      can [ :update ], ::CoTailors::Address do |address|
        puts [ user.inspect, address.inspect ], '+++ user in cancancan'
        true
      end

    end
    #
    # anonymous user
    #
    user ||= User.new

    can [ :index, :show ], City

    can [ :update ], ::CoTailors::Address
    can [ :add ], ::CoTailors::OrderItem
    can [ :create, :update_measurements ], ::CoTailors::Order
    can [ :show ], ::CoTailors::Product

    can [ :index, :show ], Event

    can [ :index ], Gallery
    can [ :show ], Gallery do |gallery|
      gallery.is_public
    end

    can [ :index ], Report
    can [ :my_index, :show ], Report do |report|
      report.is_public
    end
    
    can [ :welcome_home, :fb_sign_in, :open_permission ], Ishapi

    can [ :index, :show ], Site

    can [ :index ], Tag
    can [ :show ], Tag do |tag|
      tag.is_public
    end

    can [ :index ], Venue
    can [ :show ], Venue do |venue|
      venue.is_public
    end
    can [ :index ], Video
    can [ :show ], Video do |video|
      video.is_public
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ishapi-0.1.8.78 app/models/ishapi/ability.rb
ishapi-0.1.8.77 app/models/ishapi/ability.rb
ishapi-0.1.8.76 app/models/ishapi/ability.rb
ishapi-0.1.8.75 app/models/ishapi/ability.rb
ishapi-0.1.8.73 app/models/ishapi/ability.rb
ishapi-0.1.8.72 app/models/ishapi/ability.rb
ishapi-0.1.8.71 app/models/ishapi/ability.rb