class AffairsOfState::Config
Constants
- DISALLOWED_STATUSES
Attributes
allow_blank[R]
column[R]
if[R]
methods_for_statuses[R]
scopes[R]
statuses[R]
Public Class Methods
new(statuses:, column:, allow_blank:, scopes:, if:, prefix:)
click to toggle source
# File lib/affairs_of_state/config.rb, line 8 def initialize(statuses:, column:, allow_blank:, scopes:, if:, prefix:) @column = column @allow_blank = !!allow_blank @scopes = !!scopes @if = binding.local_variable_get(:if) @prefix = prefix.presence @statuses = statuses.flatten.map(&:to_s) @methods_for_statuses = @statuses.to_h do |s| if @prefix [s.to_s, "#{ prefix }_#{ s }"] else [s.to_s, s.to_s] end end @statuses.each do |status| raise ArgumentError.new("Affairs of State: '#{ status }' is not a valid status") if DISALLOWED_STATUSES.include?(status) end end