Module: TingYun::Frameworks::ClassMethods
- Included in:
- Framework
- Defined in:
- lib/ting_yun/frameworks/class_methods.rb
Instance Method Summary collapse
- #instance ⇒ Object
- #load_framework_class(framework) ⇒ Object
- #load_test_framework ⇒ Object
- #local_env ⇒ Object
-
#reset ⇒ Object
clear out memoized Framework and LocalEnv instances.
Instance Method Details
#instance ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/ting_yun/frameworks/class_methods.rb', line 10 def instance framework = TingYun::Agent.config[:framework] if framework == :test @instance ||= load_test_framework else @instance ||= load_framework_class(framework).new(local_env) end end |
#load_framework_class(framework) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/ting_yun/frameworks/class_methods.rb', line 27 def load_framework_class(framework) begin require 'ting_yun/frameworks/' + framework.to_s rescue LoadError #to avoid error end TingYun::Frameworks.const_get(framework.to_s.capitalize) end |
#load_test_framework ⇒ Object
20 21 22 23 24 |
# File 'lib/ting_yun/frameworks/class_methods.rb', line 20 def load_test_framework config = File.(File.join('..','..', 'test','config','tingyun.yml'), __FILE__) require 'config/test' TingYun::Frameworks::Test.new(local_env, config) end |
#local_env ⇒ Object
36 37 38 |
# File 'lib/ting_yun/frameworks/class_methods.rb', line 36 def local_env @local_env ||= TingYun::Support::LocalEnvironment.new end |
#reset ⇒ Object
clear out memoized Framework and LocalEnv instances
41 42 43 44 |
# File 'lib/ting_yun/frameworks/class_methods.rb', line 41 def reset @instance = nil @local_env = nil end |