class Middleman::Application
def self.cache
-
(Middleman::Util::Cache)
- The cache
Other tags:
- Private: -
def self.cache @_cache ||= ::Middleman::Util::Cache.new end
def build?; environment == :build; end
-
(Boolean)
- If we're in build mode
def build?; environment == :build; end
def defaults
-
(Hash)
- Hash of default values
Other tags:
- Private: -
def defaults @defaults ||= {} end
def development?; environment == :development; end
-
(Boolean)
- If we're in dev mode
def development?; environment == :development; end
def full_path(path)
-
(String)
- Path with index file if necessary
Parameters:
-
path
(String
) -- Request path
Other tags:
- Private: -
def full_path(path) cache.fetch(:full_path, path) do parts = path ? path.split('/') : [] if parts.last.nil? || parts.last.split('.').length == 1 path = File.join(path, index_file) end "/" + path.sub(%r{^/}, '') end end
def helpers(*extensions, &block)
-
(void)
-
def helpers(*extensions, &block) class_eval(&block) if block_given? include(*extensions) if extensions.any? end
def initialize(&block)
def initialize(&block) # Current path defaults to nil, used in views. self.current_path = nil # Clear the static class cache cache.clear # Setup the default values from calls to set before initialization self.class.superclass.defaults.each { |k,v| set(k,v) } # Evaluate a passed block if given instance_exec(&block) if block_given? # Build expanded source path once paths have been parsed path = root.dup source_path = ENV["MM_SOURCE"] || self.source path = File.join(root, source_path) unless source_path.empty? set :source_dir, path super end
def logging?
-
(Boolean)
- If we're logging
def logging? logging end
def set(key, value=nil, &block)
-
(void)
-
Parameters:
-
value
() -- Default value
-
key
(Symbol
) -- Unique key name
def set(key, value=nil, &block) @defaults ||= {} @defaults[key] = value @inst.set(key, value, &block) if @inst end
def set(key, value=nil, &block)
-
(void)
-
Parameters:
-
value
() -- Attribute value
-
key
(Symbol
) -- Name of the attribue
def set(key, value=nil, &block) setter = "#{key}=".to_sym self.class.send(:attr_accessor, key) if !respond_to?(setter) value = block if block_given? send(setter, value) end
def settings
-
(Middleman::Application)
-
def settings self end