Class: Transfer::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/transfer/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Config

Returns a new instance of Config.



5
6
7
8
9
# File 'lib/transfer/config.rb', line 5

def initialize data = {}
  data.each do |key, value|
    send "#{key}=", value
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/transfer/config.rb', line 23

def method_missing name, *args, &block
  /^((validate|failure_strategy|failure|before|after|success)|\w+)(=)?$/.match name
  opt = $2 ? process_options : connection_options
  if block_given?
    opt[$1.to_sym] = block
  else
    $3 ? opt[$1.to_sym] = args[0] : opt[name]
  end
end

Instance Method Details

#connectionObject



19
20
21
# File 'lib/transfer/config.rb', line 19

def connection
  @connection ||= Sequel.connect connection_options
end

#connection_optionsObject



11
12
13
# File 'lib/transfer/config.rb', line 11

def connection_options
  @connection_options ||= {}
end

#process_optionsObject



15
16
17
# File 'lib/transfer/config.rb', line 15

def process_options
  @process_options ||= { :validate => true, :failure_strategy => :ignore }
end