Module: Gecko::Helpers::RecordHelper

Included in:
Client
Defined in:
lib/gecko/helpers/record_helper.rb

Overview

Helper for registering valid record types

Instance Method Summary collapse

Instance Method Details

#record(record_type) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Registers a record type on the Gecko::Client

Examples:

class Gecko::Client
  record :Invoice
end

Returns:

  • (undefined)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gecko/helpers/record_helper.rb', line 17

def record(record_type)
  define_method record_type do
    adapter_cache = "@#{record_type}_cache".to_sym
    unless instance_variable_defined?(adapter_cache)
      adapter_name  = "#{record_type}Adapter".to_sym
      adapter_klass = Gecko::Record.const_get(adapter_name)
      adapter = adapter_klass.new(self, record_type)
      instance_variable_set(adapter_cache, adapter)
    end
    instance_variable_get(adapter_cache)
  end
end