Module: SafetyCone::Configuration
- Included in:
- SafetyCone
- Defined in:
- lib/safety_cone/configuration.rb
Overview
Module for configuring safety measures
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#features ⇒ Object
Returns the value of attribute features.
-
#options ⇒ Object
Returns the value of attribute options.
-
#paths ⇒ Object
Returns the value of attribute paths.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#add(options = {}) ⇒ Object
Method add a route or method to be managed by safety cone.
-
#configure {|_self| ... } ⇒ Object
Configuration method for Rails initializer.
-
#make_key ⇒ Object
Method to generate a key from the options.
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
4 5 6 |
# File 'lib/safety_cone/configuration.rb', line 4 def auth @auth end |
#features ⇒ Object
Returns the value of attribute features.
4 5 6 |
# File 'lib/safety_cone/configuration.rb', line 4 def features @features end |
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/safety_cone/configuration.rb', line 4 def @options end |
#paths ⇒ Object
Returns the value of attribute paths.
4 5 6 |
# File 'lib/safety_cone/configuration.rb', line 4 def paths @paths end |
#redis ⇒ Object
Returns the value of attribute redis.
4 5 6 |
# File 'lib/safety_cone/configuration.rb', line 4 def redis @redis end |
Instance Method Details
#add(options = {}) ⇒ Object
Method add a route or method to be managed by safety cone
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/safety_cone/configuration.rb', line 7 def add( = {}) self. = raise(ArgumentError, 'Mandatory param :name missing') unless [:name] if [:feature] features << SafetyCone::ViewHelpers.add_method([:feature]) else paths[make_key] = end end |
#configure {|_self| ... } ⇒ Object
Configuration method for Rails initializer
33 34 35 36 37 38 39 |
# 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 ⇒ Object
Method to generate a key from the options
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/safety_cone/configuration.rb', line 21 def make_key if .key? :method [:method].to_sym elsif .include?(:controller) && .include?(:action) "#{[:controller]}_#{[:action]}".to_sym else raise(ArgumentError, 'Options should contain :controller and :action or :method.') end end |