Sha256: fd452de31e1cf237864a6e1fbed1b401ed6835a9d8f3de4ef834655dfcd19432
Contents?: true
Size: 962 Bytes
Versions: 9
Compression:
Stored size: 962 Bytes
Contents
class Ability include CanCan::Ability def initialize(user) user ||= User.new # anonymous user (not logged in) # Rails Application's initialization could go here. initialize_paid_up(user) end def initialize_paid_up(user) features = PaidUp::Feature.all for feature in features case feature.setting_type when 'table_rows' model = feature.name.classify.constantize if user.table_rows_allowed(feature.name) > 0 || user.table_rows_allowed(feature.name) == -1 can :manage, model, :user => user can :own, model unless user.table_rows_remaining(feature.name) > 0 cannot :create, model end end can :read, model when 'boolean' if user.plan.feature_setting feature.id can :use, feature.name.to_sym end else raise(:unknown_feature_type.l) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems