Class: ImpExp::Serializers::Errors::RecordNotFound

Inherits:
Base
  • Object
show all
Defined in:
app/services/imp_exp/serializers/errors/record_not_found.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(active_record_class, find_args) ⇒ RecordNotFound

Returns a new instance of RecordNotFound.



9
10
11
12
13
14
# File 'app/services/imp_exp/serializers/errors/record_not_found.rb', line 9

def initialize(active_record_class, find_args)
  super()
  @active_record_class = active_record_class
  @active_record_class = @active_record_class.constantize if @active_record_class.is_a?(String)
  @find_args = find_args&.symbolize_keys
end

Instance Attribute Details

#active_record_classObject (readonly)

Returns the value of attribute active_record_class.



7
8
9
# File 'app/services/imp_exp/serializers/errors/record_not_found.rb', line 7

def active_record_class
  @active_record_class
end

#find_argsObject (readonly)

Returns the value of attribute find_args.



7
8
9
# File 'app/services/imp_exp/serializers/errors/record_not_found.rb', line 7

def find_args
  @find_args
end

Instance Method Details

#messageObject



16
17
18
19
20
# File 'app/services/imp_exp/serializers/errors/record_not_found.rb', line 16

def message
  conditions = find_args.map { |k, v| "#{k}=#{v}" }.join(' ')
  I18n.t('imp_exp.importer.record_not_found', model_name: active_record_class.model_name,
                                              conditions: conditions)
end