Class: Floom::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/floom/models/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Returns a new instance of Configuration.



23
24
25
26
27
28
29
30
# File 'lib/floom/models/configuration.rb', line 23

def initialize(options = {}) 
  @source         = options[:source]
  @sink           = options[:sink]
  @flow           = options[:flow]
  @source_version = options[:source_version]
  @sink_version   = options[:sink_version]
  @timestamp      = options[:timestamp]
end

Class Method Details

.create(options = {}, &blk) ⇒ Object



15
16
17
18
19
# File 'lib/floom/models/configuration.rb', line 15

def create(options = {}, &blk)
  config = new(options)
  config.instance_eval(&blk) if block_given?
  config
end

.parse(conf) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/floom/models/configuration.rb', line 6

def parse(conf)
  new(source:         conf.sourceConfig,
      sink:           conf.sinkConfig, 
      flow:           conf.flowID,            
      source_version: conf.sourceVersion,
      sink_version:   conf.sinkVersion, 
      timestamp:      conf.timestamp).to_hash
end

Instance Method Details

#flow(val = nil) ⇒ Object



47
48
49
50
# File 'lib/floom/models/configuration.rb', line 47

def flow(val = nil)
  @flow = val if val
  @flow
end

#sink(val = nil) ⇒ Object



42
43
44
45
# File 'lib/floom/models/configuration.rb', line 42

def sink(val = nil)
  @sink = val if val
  @sink
end

#sink_version(val = nil) ⇒ Object



57
58
59
60
# File 'lib/floom/models/configuration.rb', line 57

def sink_version(val = nil)
  @sink_version = val if val
  @sink_version
end

#source(val = nil) ⇒ Object



37
38
39
40
# File 'lib/floom/models/configuration.rb', line 37

def source(val = nil)
  @source = val if val
  @source
end

#source_version(val = nil) ⇒ Object



52
53
54
55
# File 'lib/floom/models/configuration.rb', line 52

def source_version(val = nil)
  @source_version = val if val
  @source_version
end

#timestamp(val = nil) ⇒ Object



32
33
34
35
# File 'lib/floom/models/configuration.rb', line 32

def timestamp(val = nil)
  @timestamp = val if val
  @timestamp
end

#to_hashObject



62
63
64
# File 'lib/floom/models/configuration.rb', line 62

def to_hash
  self.instance_variables.map{ |var| var.to_s.slice(1..-1).to_sym }.inject({}){ |hsh, var| hsh[var] = self.send(var) ; hsh }
end

#to_paramsObject



66
67
68
# File 'lib/floom/models/configuration.rb', line 66

def to_params
  [ flow, source, sink ].compact
end