module BloodContracts::Core::DefineableError

Meta class to define local errors in form of Tram::Policy::Errors

Public Class Methods

extended(other) click to toggle source
# File lib/blood_contracts/core/defineable_error.rb, line 51
def self.extended(other)
  other.instance_variable_set(
    :@policy_scope, instance_variable_get(:@policy_scope)
  )
end
new(policy_scope) click to toggle source

Method that creates meta class for defining custom Tram::Policy::Errors

@param policy_scope [Symbol] is a root for your I18n translations @return [Module]

# File lib/blood_contracts/core/defineable_error.rb, line 49
def new(policy_scope)
  m = Module.new do
    def self.extended(other)
      other.instance_variable_set(
        :@policy_scope, instance_variable_get(:@policy_scope)
      )
    end
  end
  m.include(Concern)
  m.instance_variable_set(:@policy_scope, policy_scope)
  m
end