Class: Veriff::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/veriff/model.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_hash) ⇒ Model

Returns a new instance of Model.



5
6
7
8
# File 'lib/veriff/model.rb', line 5

def initialize(data_hash)
  data_hash.fetch(:id)
  @data_hash = data_hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *_args) ⇒ Object



14
15
16
# File 'lib/veriff/model.rb', line 14

def method_missing(method_name, *_args)
  @data_hash.key?(method_name) ? @data_hash[method_name] : super
end

Class Method Details

.api_collection_nameObject



18
19
20
# File 'lib/veriff/model.rb', line 18

def self.api_collection_name
  "#{name.gsub('Veriff::', '').downcase}s"
end

Instance Method Details

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/veriff/model.rb', line 10

def respond_to_missing?(method_name, include_private = false)
  @data_hash.key?(method_name) || super
end