Sha256: 87ab57889b53a0e0a175d951ea1c259d1409812403158f4b2e0bad589f81911a

Contents?: true

Size: 840 Bytes

Versions: 21

Compression:

Stored size: 840 Bytes

Contents

module Gecko
  module Helpers
    # Helper for registering valid record types
    module RecordHelper
      # Registers a record type on the Gecko::Client
      #
      # @example
      #  class Gecko::Client
      #    record :Invoice
      #  end
      #
      # @return [undefined]
      #
      # @api private
      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
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gecko-ruby-0.9.1 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.9.0 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.8.0 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.2.6 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.7.1 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.7.0 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.6.0 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.5.0 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.2.5 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.2.4 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.2.3 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.2.2 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.2.0 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.1.0 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.0.10 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.0.9 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.0.8 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.0.7 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.0.6 lib/gecko/helpers/record_helper.rb
gecko-ruby-0.0.5 lib/gecko/helpers/record_helper.rb