module StateGate::Engine::Fixer

Description

Provides prefix and suffix helper methods for StateGate::Engine.

Public Instance Methods

prefix(val = nil) click to toggle source

A phrase to add before state names when using Class Scopes. This helps differential attributes that have similar state names. (Symbol | optional)

prefix :before  # => Class.before_active
# File lib/state_gate/engine/fixer.rb, line 22
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() click to toggle source

Returns the defined prefix for the state_gate, or an empty string if no prefix has been defined.

.state_prefix   # => 'my_prefix'
.state_prefix   # => ''
# File lib/state_gate/engine/fixer.rb, line 55
def state_prefix
  @prefix
end
state_suffix() click to toggle source

Returns the defined suffix for the state_gate, or an empty string if no suffix has been defined.

.state_suffix   # => 'my_suffix'
.state_suffix   # => ''
# File lib/state_gate/engine/fixer.rb, line 68
def state_suffix
  @suffix
end
suffix(val = nil) click to toggle source

A phrase to add before state names when using Class Scopes. This helps differential attributes that have similar state names. (Symbol | optional)

suffix :after  # => Class.active_after
# File lib/state_gate/engine/fixer.rb, line 36
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