Class: RemoteRecord::ClassLookup

Inherits:
Object
  • Object
show all
Defined in:
lib/remote_record/class_lookup.rb

Overview

Looks up the class name to use to define the remote record’s behavior.

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ ClassLookup

Returns a new instance of ClassLookup.



6
7
8
# File 'lib/remote_record/class_lookup.rb', line 6

def initialize(klass)
  @klass = klass
end

Instance Method Details

#remote_record_class(class_name_override = nil) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/remote_record/class_lookup.rb', line 10

def remote_record_class(class_name_override = nil)
  class_name = (class_name_override || infer_remote_record_class_name)
  class_name.constantize
rescue NameError
  raise RemoteRecord::RecordClassNotFound, "#{class_name} couldn't be found." \
  "#{' Perhaps you need to define `remote_record_class`?' unless class_name_override}"
end