Module: Tr8n
- Defined in:
- lib/tr8n/cache.rb,
lib/tr8n_core.rb,
lib/tr8n/utils.rb,
lib/tr8n/config.rb,
lib/tr8n/logger.rb,
lib/tr8n/session.rb,
lib/tr8n/tokens/data.rb,
lib/tr8n/rules_engine/parser.rb,
lib/tr8n/tokens/data_tokenizer.rb,
lib/tr8n/rules_engine/evaluator.rb,
lib/tr8n/tokens/decoration_tokenizer.rb
Overview
Decoration Token Forms:
- link: click here
-
or
- link
-
click here [/link]
Decoration Tokens Allow Nesting:
- link: count _messages
- link: count||message
- link: people
- link: useruser.name
Defined Under Namespace
Modules: CacheAdapters, Decorators, Rules, RulesEngine, Tokens Classes: ApiClient, Application, Base, Cache, Component, Config, Exception, Language, LanguageCase, LanguageCaseRule, LanguageContext, LanguageContextRule, Logger, Session, Source, Translation, TranslationKey, Translator, Utils
Class Attribute Summary collapse
-
.config ⇒ Object
Initializes default config.
Class Method Summary collapse
- .cache ⇒ Object
-
.configure {|self.config| ... } ⇒ Object
Allows you to configure Tr8n.
- .logger ⇒ Object
- .session ⇒ Object
-
.with_config_settings {|@config| ... } ⇒ Object
Allows you to create a block to perform something on adjusted config settings Once the block exists, the config will be reset back to what it was before:.
Class Attribute Details
.config ⇒ Object
Initializes default config
33 34 35 |
# File 'lib/tr8n/config.rb', line 33 def config @config end |
Class Method Details
.cache ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tr8n/cache.rb', line 27 def self.cache @cache ||= begin if Tr8n.config.cache[:enabled] klass = Tr8n::CacheAdapters.const_get(Tr8n.config.cache[:adapter].camelcase) klass.new else # blank implementation Tr8n::Cache.new end end end |
.configure {|self.config| ... } ⇒ Object
Allows you to configure Tr8n
Tr8n.configure do |config|
config.application = {:key => "", :secret => ""}
end
45 46 47 |
# File 'lib/tr8n/config.rb', line 45 def self.configure yield(self.config) end |
.logger ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tr8n/logger.rb', line 29 def self.logger @logger ||= begin logfile_path = File.(Tr8n.config.logger[:path]) logfile_dir = logfile_path.split("/")[0..-2].join("/") FileUtils.mkdir_p(logfile_dir) unless File.exist?(logfile_dir) logfile = File.open(logfile_path, 'a') logfile.sync = true Tr8n::Logger.new(logfile) end end |
.session ⇒ Object
27 28 29 |
# File 'lib/tr8n/session.rb', line 27 def self.session Thread.current[:session] ||= Tr8n::Session.new end |
.with_config_settings {|@config| ... } ⇒ Object
Allows you to create a block to perform something on adjusted config settings Once the block exists, the config will be reset back to what it was before:
Tr8n.with_config_settings do |config|
config.format = :text
Do something....
end
60 61 62 63 64 |
# File 'lib/tr8n/config.rb', line 60 def self.with_config_settings old_config = @config.dup yield(@config) @config = old_config end |