Class: Wukong::Store::Base

Inherits:
Object show all
Defined in:
lib/wukong/store/base.rb

Direct Known Subclasses

FlatFileStore

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



4
5
6
# File 'lib/wukong/store/base.rb', line 4

def initialize options={}
  Log.info "Creating #{self.class} with #{options.inspect}"
end

Instance Method Details

#each_as(klass, &block) ⇒ Object

Iterate through each object casting it as a new object of klass.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/wukong/store/base.rb', line 9

def each_as klass, &block
  self.each do |*args|
    begin
      item = klass.new *args[1..-1]
    rescue StandardError => e
      Log.info [args, e.to_s, self].join("\t")
      raise e
    end
    yield item
  end
end

#log_lineObject



21
22
23
# File 'lib/wukong/store/base.rb', line 21

def log_line
  nil
end