Module: Rgentpl
- Defined in:
- lib/rgentpl.rb,
lib/rgentpl/version.rb,
lib/rgentpl/command/base.rb,
lib/rgentpl/core_ext/string.rb,
lib/rgentpl/boot/application.rb,
lib/rgentpl/boot/initializer.rb,
lib/rgentpl/command/generate.rb,
lib/rgentpl/core/configuration.rb,
lib/rgentpl/exception/critical.rb
Overview
Rgentpl
Defined Under Namespace
Modules: Application, Command, CoreExt, Exception, Initializer Classes: Configuration
Constant Summary collapse
- VERSION =
Version
'1.2.5'
Class Method Summary collapse
-
.add_new_attribute(exc, method) ⇒ void
Implementation for adding new attribute in configuration block.
-
.add_new_attribute_from_exception(exc) ⇒ void
Interface for adding new attribute in configuration block.
-
.config ⇒ Rgentpl::Configuration
Configuration object.
-
.configure(&_block) ⇒ Rgentpl::Configuration
Configure.
-
.env ⇒ String
Environment.
-
.logger ⇒ Logger
Logger.
Class Method Details
.add_new_attribute(exc, method) ⇒ void
This method returns an undefined value.
Implementation for adding new attribute in configuration block
35 36 37 38 39 40 |
# 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 |
.add_new_attribute_from_exception(exc) ⇒ void
This method returns an undefined value.
Interface for adding new attribute in configuration block
26 27 28 |
# 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 ⇒ Rgentpl::Configuration
Configuration object
18 19 20 |
# File 'lib/rgentpl/core/configuration.rb', line 18 def config @config ||= Rgentpl::Configuration.new end |
.configure(&_block) ⇒ Rgentpl::Configuration
Configure
9 10 11 12 13 |
# 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 ⇒ String
Environment
32 33 34 35 36 37 |
# File 'lib/rgentpl.rb', line 32 def env unless defined?(TEMPLATE_ENV) load File.('../../config/environment.rb', __FILE__) end TEMPLATE_ENV end |
.logger ⇒ Logger
Logger
42 43 44 45 46 |
# File 'lib/rgentpl.rb', line 42 def logger @_logger ||= Logger.new( "#{File.dirname(__FILE__)}/../log/#{config.log_file}" ) end |