class Railsless::ActiveRecord::Config

Attributes

root[W]

An overblown way of figuring out where the calling application’s root is, borrowed from Rails.

Public Class Methods

accessor_with_default(name, &block) click to toggle source
# File lib/railsless/active_record/config.rb, line 9
def self.accessor_with_default(name, &block)
  module_eval do
    attr_writer name
    define_method(name) do
      # Don't cache the result; if you really needs to, define a method manually.
      instance_variable_get(:"@#{name}") || instance_exec(&block)
    end
  end
end
new(overrides={}) click to toggle source
# File lib/railsless/active_record/config.rb, line 19
def initialize(overrides={})
  overrides.each { |attr,val| send(:"#{attr}=", val) }
end

Public Instance Methods

root() click to toggle source
# File lib/railsless/active_record/config.rb, line 26
def root
  @root ||= Root.calculate
end

Protected Instance Methods

read_config(filename) click to toggle source

Intentionally explodes violently if the file doesn’t exist.

# File lib/railsless/active_record/config.rb, line 59
def read_config(filename)
  ERB.new(File.read(filename)).result
end