class Falcore::Dumper::Base

Attributes

config[R]

@return [Falcore::Config]

master[R]

@return [Falcore::Node::Master]

Public Class Methods

new(config, master) click to toggle source

@param [Config] config

the config object

@param [Node::Master] master

the master node
# File lib/falcore/dumpers/base.rb, line 43
def initialize(config, master)
  unless config.is_a?(Config)
    raise ArgumentError, "#{config.class} is not an Falcore::Config"
  end

  unless master.is_a?(Node::Master)
    raise ArgumenError, "#{config.class} is not an Falcore::Node::Master"
  end

  @config = config
  @master = master
end
run(&block) click to toggle source
# File lib/falcore/dumpers/base.rb, line 22
def run(&block)
  block ? @run = block : @run || Proc.new
end
validate(&block) click to toggle source
# File lib/falcore/dumpers/base.rb, line 26
def validate(&block)
  block ? @validate = block : @validate || Proc.new
end

Public Instance Methods

run() click to toggle source

Run this dumper. This method should be overridden in subclasses.

# File lib/falcore/dumpers/base.rb, line 59
def run
  instance_eval(&self.class.validate)
  instance_eval(&self.class.run)
end

Private Instance Methods

presence!(thing, &block) click to toggle source

Ensure the thing called in the block is not nil.

@param [String] thing

the thing to check (used for the error message)

@param [Proc] block

the block to call

@return [true]

# File lib/falcore/dumpers/base.rb, line 76
def presence!(thing, &block)
  if block.call(self).nil?
    raise "Expected '#{thing}' to be set!"
  end

  true
end