module SafetyCone::Configuration
Module for configuring safety measures
Attributes
auth[RW]
features[RW]
options[RW]
paths[RW]
redis[RW]
Public Instance Methods
add(options = {})
click to toggle source
Method add a route or method to be managed by safety cone
# File lib/safety_cone/configuration.rb, line 7 def add(options = {}) self.options = options raise(ArgumentError, 'Mandatory param :name missing') unless options[:name] if options[:feature] features << options SafetyCone::ViewHelpers.add_method(options[:feature]) else paths[make_key] = options end end
configure() { |self| ... }
click to toggle source
Configuration
method for Rails initializer
# File lib/safety_cone/configuration.rb, line 33 def configure self.paths = {} self.features = [] self.auth = { username: nil, password: nil } yield self end
make_key()
click to toggle source
Method to generate a key from the options
# File lib/safety_cone/configuration.rb, line 21 def make_key if options.key? :method options[:method].to_sym elsif options.include?(:controller) && options.include?(:action) "#{options[:controller]}_#{options[:action]}".to_sym else raise(ArgumentError, 'Options should contain :controller and :action or :method.') end end