Class: EacRubyUtils::CommonConcern::ClassSetup
- Includes:
- SimpleCache
- Defined in:
- lib/eac_ruby_utils/common_concern/class_setup.rb
Constant Summary
Constants included from SimpleCache
SimpleCache::UNCACHED_METHOD_NAME_SUFFIX, SimpleCache::UNCACHED_METHOD_PATTERN
Instance Attribute Summary collapse
-
#a_class ⇒ Object
readonly
Returns the value of attribute a_class.
-
#include_method ⇒ Object
readonly
Returns the value of attribute include_method.
-
#module_setup ⇒ Object
readonly
Returns the value of attribute module_setup.
Instance Method Summary collapse
- #class_methods_module_uncached ⇒ Object
-
#initialize(module_setup, a_class, include_method) ⇒ ClassSetup
constructor
A new instance of ClassSetup.
- #instance_methods_module_uncached ⇒ Object
- #run ⇒ Object
- #setup_after_callback ⇒ Object
- #setup_class_methods ⇒ Object
- #setup_instance_methods ⇒ Object
Methods included from SimpleCache
#method_missing, #reset_cache, #respond_to_missing?, #sanitize_cache_key, uncached_method_name
Constructor Details
#initialize(module_setup, a_class, include_method) ⇒ ClassSetup
Returns a new instance of ClassSetup.
13 14 15 16 17 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 13 def initialize(module_setup, a_class, include_method) @module_setup = module_setup @a_class = a_class @include_method = include_method end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class EacRubyUtils::SimpleCache
Instance Attribute Details
#a_class ⇒ Object (readonly)
Returns the value of attribute a_class.
11 12 13 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 11 def a_class @a_class end |
#include_method ⇒ Object (readonly)
Returns the value of attribute include_method.
11 12 13 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 11 def include_method @include_method end |
#module_setup ⇒ Object (readonly)
Returns the value of attribute module_setup.
11 12 13 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 11 def module_setup @module_setup end |
Instance Method Details
#class_methods_module_uncached ⇒ Object
39 40 41 42 43 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 39 def class_methods_module_uncached module_setup.a_module.const_get(CLASS_METHODS_MODULE_NAME) rescue NameError nil end |
#instance_methods_module_uncached ⇒ Object
45 46 47 48 49 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 45 def instance_methods_module_uncached module_setup.a_module.const_get(INSTANCE_METHODS_MODULE_NAME) rescue NameError nil end |
#run ⇒ Object
19 20 21 22 23 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 19 def run %w[class_methods instance_methods after_callback].each do |suffix| send("setup_#{suffix}") end end |
#setup_after_callback ⇒ Object
33 34 35 36 37 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 33 def setup_after_callback module_setup.common_concern.after_callback.if_present do |v| a_class.instance_eval(&v) end end |
#setup_class_methods ⇒ Object
25 26 27 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 25 def setup_class_methods class_methods_module.if_present { |v| a_class.extend v } end |
#setup_instance_methods ⇒ Object
29 30 31 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 29 def setup_instance_methods instance_methods_module.if_present { |v| a_class.send(include_method, v) } end |