module FinePrint::ActionController::Base::ClassMethods
Public Instance Methods
fine_print_require(*names)
click to toggle source
Accepts an array of contract names and an options hash Adds a before_action to the current controller that will check if the current user has signed the given contracts and call the sign_proc if appropriate Options relevant to FinePrint
are passed to fine_print_sign, while other options are passed to the before_action
# File lib/fine_print/action_controller/base.rb, line 74 def fine_print_require(*names) options = names.last.is_a?(Hash) ? names.pop : {} f_opts = options.except(*FinePrint::Configuration::CONTROLLER_OPTIONS) # Convert names to an array of Strings contract_names = names.flatten.collect{|c| c.to_s} contract_names = ['all'] if contract_names.empty? class_exec do before_action(f_opts) do |controller| skipped_contract_names = fine_print_skipped_contract_names next if skipped_contract_names.include?('all') contract_names = FinePrint::Contract.all.to_a.collect{|c| c.name} .uniq if contract_names.include?('all') unskipped_contract_names = contract_names - skipped_contract_names controller.fine_print_require(unskipped_contract_names, options) \ unless unskipped_contract_names.empty? end end end
fine_print_skip(*names)
click to toggle source
Accepts an array of contract names and an options hash Excludes the given contracts from the ‘fine_print_require` check for this controller and subclasses Options are passed to prepend_before_action
# File lib/fine_print/action_controller/base.rb, line 99 def fine_print_skip(*names) options = names.last.is_a?(Hash) ? names.pop : {} # Convert names to an array of Strings contract_names = names.flatten.collect{|c| c.to_s} contract_names = ['all'] if contract_names.empty? class_exec do prepend_before_action(options) do |controller| controller.fine_print_skipped_contract_names.push(*contract_names) end end end