class Leda::Configuration

Attributes

base_path[R]

Public Class Methods

new(&dsl) click to toggle source
# File lib/leda/configuration.rb, line 9
def initialize(&dsl)
  @data_units_map = {}
  @base_path = Pathname.new('db/leda')

  if block_given?
    update(&dsl)
  end
end

Public Instance Methods

base_dir() click to toggle source
# File lib/leda/configuration.rb, line 49
def base_dir
  project_root_dir + base_path
end
base_path=(path) click to toggle source
# File lib/leda/configuration.rb, line 45
def base_path=(path)
  @base_path = ensure_pathname(path)
end
data_unit(name, &dsl) click to toggle source
# File lib/leda/configuration.rb, line 23
def data_unit(name, &dsl)
  data_unit = (@data_units_map[name] ||= DataUnit.new(name))

  if block_given?
    dsl.call(DataUnitConfigurator.new(data_unit))
  end

  data_unit
end
data_units() click to toggle source
# File lib/leda/configuration.rb, line 33
def data_units
  @data_units_map.values
end
project_root_dir() click to toggle source
# File lib/leda/configuration.rb, line 37
def project_root_dir
  @project_root_dir or fail "Please set project_root_dir in your Leda configuration"
end
project_root_dir=(path) click to toggle source
# File lib/leda/configuration.rb, line 41
def project_root_dir=(path)
  @project_root_dir = ensure_pathname(path)
end
update(&dsl) click to toggle source
# File lib/leda/configuration.rb, line 18
def update(&dsl)
  dsl.call(self)
  self
end

Private Instance Methods

ensure_pathname(path) click to toggle source
# File lib/leda/configuration.rb, line 55
def ensure_pathname(path)
  case path
  when Pathname
    path
  when nil
    nil
  else
    Pathname.new(path.to_s)
  end
end