class Pieces::Config

Attributes

env[RW]
path[R]

Public Class Methods

new(config = {}) click to toggle source
# File lib/pieces/config.rb, line 9
def initialize(config = {})
  @path = config.delete(:path) || Dir.pwd
  merge!(config)
  load_config! unless config[:load] == false
end

Public Instance Methods

asset_prefix() click to toggle source
# File lib/pieces/config.rb, line 31
def asset_prefix
  self['_asset_prefix']
end
globals() click to toggle source
# File lib/pieces/config.rb, line 19
def globals
  self['_global'] || {}
end
mounted_at() click to toggle source
# File lib/pieces/config.rb, line 35
def mounted_at
  self['_mounted_at']
end
publish_endpoint() click to toggle source
# File lib/pieces/config.rb, line 23
def publish_endpoint
  if has_key?('_publish')
    self['_publish'].first
  else
    raise PublisherConfigNotFound
  end
end
reload!() click to toggle source
# File lib/pieces/config.rb, line 39
def reload!
  load_config!
end
routes() click to toggle source
# File lib/pieces/config.rb, line 15
def routes
  reject { |key, _| key =~ /^_/ }
end

Private Instance Methods

load_config!() click to toggle source
# File lib/pieces/config.rb, line 45
def load_config!
  if File.exists?("#{path}/config/pieces.yml")
    merge!(YAML.load_file("#{path}/config/pieces.yml"))
  else
    raise ConfigNotFound.new("We could not find pieces.yml in #{path}/config/")
  end
end