module Rgentpl
@author julio.antunez.tarin@gmail.com
Constants
- VERSION
Version
Public Class Methods
add_new_attribute_from_exception(exc)
click to toggle source
Interface for adding new attribute in configuration block
@param exc [NoMethodError] the exception @return [void]
# File lib/rgentpl/core/configuration.rb, line 26 def add_new_attribute_from_exception(exc) add_new_attribute(exc, exc.name.to_s.gsub(/=$/, '')) end
config()
click to toggle source
Configuration
object
@return [Rgentpl::Configuration] the configuration object
# File lib/rgentpl/core/configuration.rb, line 18 def config @config ||= Rgentpl::Configuration.new end
configure() { |config ||= configuration| ... }
click to toggle source
Configure
@param _block [Proc] the configuration options @raise [NoMethodError] when new options are inside configuration block @return [Rgentpl::Configuration] the configuration
# File lib/rgentpl/core/configuration.rb, line 9 def configure(&_block) yield @config ||= Rgentpl::Configuration.new rescue NoMethodError => exc add_new_attribute_from_exception exc end
env()
click to toggle source
Environment
@return [String] the current environment
# File lib/rgentpl.rb, line 32 def env unless defined?(TEMPLATE_ENV) load File.expand_path('../../config/environment.rb', __FILE__) end TEMPLATE_ENV end
logger()
click to toggle source
Logger
@return [Logger] the logger
# File lib/rgentpl.rb, line 42 def logger @_logger ||= Logger.new( "#{File.dirname(__FILE__)}/../log/#{config.log_file}" ) end
Private Class Methods
add_new_attribute(exc, method)
click to toggle source
Implementation for adding new attribute in configuration block
@param exc [NoMethodError] the exception @param method [String] the writter method name @return [void]
# File lib/rgentpl/core/configuration.rb, line 35 def add_new_attribute(exc, method) @config.extend Virtus.model @config.attribute method.to_sym, String, default: exc.args.first, lazy: true @config.send(exc.name, exc.args.first) end