Sha256: e295837f535fbdfc010704431d530fc2286ba91fa359bda463fb5558e20904ec

Contents?: true

Size: 978 Bytes

Versions: 6

Compression:

Stored size: 978 Bytes

Contents

#
# Provides a base template for interface and behavior of contact importers

module Graybook::Importer
  class Base
    attr_accessor :options

    ##
    # Should return true or false/nil depending on whether the +options+ given 
    # can be handled by this importer

    def =~( options ); end # stub

    ##
    # Does the work of extracting contacts. Returns an Array of Arrays 
    # containing the name and email as the first and second elements. Of 
    # course, you can override this behavior to meet the needs of a 
    # particular service.

    def fetch_contacts!; end # stub

    ##
    # Imports the contacts using the given +options+. Returns an array of 
    # hashes in the internal format (a hash with at least :name and :email 
    # values).

    def import(options = {}) 
      self.options = options
      fetch_contacts!
    end

    ##
    # Name of the importer service.

    def service_name
      self.class.name.split("::").last
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
graybook-1.1.2 lib/graybook/importer/base.rb
graybook-1.1.1 lib/graybook/importer/base.rb
graybook-1.1.0 lib/graybook/importer/base.rb
graybook-1.0.24 lib/graybook/importer/base.rb
graybook-1.0.23 lib/graybook/importer/base.rb
graybook-1.0.22 lib/graybook/importer/base.rb