Module: StateGate::Engine::Fixer
- Included in:
- StateGate::Engine
- Defined in:
- lib/state_gate/engine/fixer.rb
Overview
Description
Provides prefix and suffix helper methods for StateGate::Engine.
Instance Method Summary collapse
-
#prefix(val = nil) ⇒ Object
A phrase to add before state names when using Class Scopes.
-
#state_prefix ⇒ Object
Returns the defined prefix for the state_gate, or an empty string if no prefix has been defined.
-
#state_suffix ⇒ Object
Returns the defined suffix for the state_gate, or an empty string if no suffix has been defined.
-
#suffix(val = nil) ⇒ Object
A phrase to add before state names when using Class Scopes.
Instance Method Details
#prefix(val = nil) ⇒ Object
A phrase to add before state names when using Class Scopes. This helps differential attributes that have similar state names.
26 27 28 29 30 |
# File 'lib/state_gate/engine/fixer.rb', line 26 def prefix(val = nil) _cerr(:prefix_type_err, kattr: true) unless val.is_a?(Symbol) _cerr(:prefix_multiple_err, kattr: true) if @prefix @prefix = "#{val.to_s.downcase}_" end |
#state_prefix ⇒ Object
Returns the defined prefix for the state_gate, or an empty string if no prefix has been defined.
63 64 65 |
# File 'lib/state_gate/engine/fixer.rb', line 63 def state_prefix @prefix end |
#state_suffix ⇒ Object
Returns the defined suffix for the state_gate, or an empty string if no suffix has been defined.
77 78 79 |
# File 'lib/state_gate/engine/fixer.rb', line 77 def state_suffix @suffix end |
#suffix(val = nil) ⇒ Object
A phrase to add before state names when using Class Scopes. This helps differential attributes that have similar state names.
43 44 45 46 47 |
# File 'lib/state_gate/engine/fixer.rb', line 43 def suffix(val = nil) _cerr(:suffix_type_err, kattr: true) unless val.is_a?(Symbol) _cerr(:suffix_multiple_err, kattr: true) if @suffix @suffix = "_#{val.to_s.downcase}" end |