class Exporter::Configuration

Public Class Methods

new() click to toggle source
# File lib/exporter/configuration.rb, line 4
def initialize
  @exporters = Hash.new
end

Public Instance Methods

can_export?(data, export_type) click to toggle source
# File lib/exporter/configuration.rb, line 23
def can_export?(data, export_type)
  can_export_proc = Proc.new{|key| @exporters[key][export_type].present?}
  index(data, false, can_export_proc)
end
exporter(data, export_type) click to toggle source
# File lib/exporter/configuration.rb, line 28
def exporter(data, export_type)
  exporter_proc = Proc.new {|key| @exporters[key][export_type]}
  index(data, nil, exporter_proc)
end
index(data, default_value, method) click to toggle source
# File lib/exporter/configuration.rb, line 16
def index(data, default_value, method)
  @exporters.keys.each do |key|
    return method.call(key) if data.kind_of?(key)
  end
  default_value
end
register(data_type, export_type, exporter) click to toggle source
# File lib/exporter/configuration.rb, line 8
def register(data_type, export_type, exporter)
  if @exporters[data_type].nil?
    @exporters[data_type] = {export_type => exporter}
  else
    @exporters[data_type][export_type] = exporter
  end
end