Sha256: 0fe2f7dc153d6c4c14a7852ae39a3fb8ac1874e653dcc5f8a4e073269d619ea9

Contents?: true

Size: 523 Bytes

Versions: 11

Compression:

Stored size: 523 Bytes

Contents

class CarloadDashboardPolicy < Struct.new(:user, :dashboard)
  [:index, :new, :edit, :destroy].each do |action|
    define_method :"#{action}?" do
      return true if Carload.auth_solution == :none
      return false if not user
      action = :all if not Carload.dashboard[:permits_user][action]
      Array(Carload.dashboard[:permits_user][action]).each do |permission|
        return true if eval "user.#{permission}"
      end
      false
    end
  end

  def create?
    new?
  end

  def update?
    edit?
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
carload-0.5.3 app/policies/carload_dashboard_policy.rb
carload-0.5.2 app/policies/carload_dashboard_policy.rb
carload-0.5.1 app/policies/carload_dashboard_policy.rb
carload-0.5.0 app/policies/carload_dashboard_policy.rb
carload-0.4.5 app/policies/carload_dashboard_policy.rb
carload-0.4.4 app/policies/carload_dashboard_policy.rb
carload-0.4.3 app/policies/carload_dashboard_policy.rb
carload-0.4.2 app/policies/carload_dashboard_policy.rb
carload-0.4.1 app/policies/carload_dashboard_policy.rb
carload-0.4.0 app/policies/carload_dashboard_policy.rb
carload-0.3.0 app/policies/carload_dashboard_policy.rb