Module: FinePrint::ActionController::Base::ClassMethods
- Defined in:
- lib/fine_print/action_controller/base.rb
Instance Method Summary collapse
-
#fine_print_require(*names) ⇒ Object
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.
-
#fine_print_skip(*names) ⇒ Object
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.
Instance Method Details
#fine_print_require(*names) ⇒ Object
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
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/fine_print/action_controller/base.rb', line 74 def fine_print_require(*names) = names.last.is_a?(Hash) ? names.pop : {} f_opts = .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, ) \ unless unskipped_contract_names.empty? end end end |
#fine_print_skip(*names) ⇒ Object
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
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/fine_print/action_controller/base.rb', line 99 def fine_print_skip(*names) = 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() do |controller| controller.fine_print_skipped_contract_names.push(*contract_names) end end end |