This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OfferRule | |
def initialize(user, field_or_method, field_type, threshold_value) | |
@user = user | |
@field_or_method = field_or_method.to_sym | |
@field_type = field_type | |
@threshold_value = threshold_value | |
end | |
def self.create_from_hash(user, rule_hash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Application < Rails::Application | |
#... | |
config.after_initialize do | |
method_logger_config = YAML::load(ERB.new(File.read(File.join(Rails.root, 'config/constants/method_logger.yaml'))).result)[Rails.env] | |
if Rails.env != "test" | |
Rails.application.eager_load! | |
if Rails.logger.level <= "Logger::Severity::#{method_logger_config["controller_logging_threshold"].upcase}".constantize | |
ApplicationController.subclasses.each{|c| c.send(:include, MethodLogger) unless method_logger_config["excluded_controllers"].include?(c.to_s)} | |
end | |
if Rails.logger.level <= "Logger::Severity::#{method_logger_config["model_logging_threshold"].upcase}".constantize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FilteredAbility | |
def initialize(user) | |
@user = user | |
end | |
def ability_for(obj) | |
class_abilities = organized_abilities[obj.class] | |
considers = class_abilities.keys.select{|a| @user.send(a)} | |
considers.each{|c| create_ability(class_abilities[c]) | |
end |