Class: EacRubyUtils::CommonConcern::Setup
Constant Summary
Constants included
from SimpleCache
SimpleCache::UNCACHED_METHOD_PATTERN
Instance Attribute Summary collapse
Instance Method Summary
collapse
#method_missing, #reset_cache, #respond_to_missing?
Constructor Details
#initialize(common_constructor, a_module) ⇒ Setup
26
27
28
29
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 26
def initialize(common_constructor, a_module)
@common_constructor = common_constructor
@a_module = a_module
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class EacRubyUtils::SimpleCache
Instance Attribute Details
Returns the value of attribute a_module.
24
25
26
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 24
def a_module
@a_module
end
|
#common_constructor ⇒ Object
Returns the value of attribute common_constructor.
24
25
26
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 24
def common_constructor
@common_constructor
end
|
Instance Method Details
#class_methods_module_uncached ⇒ Object
55
56
57
58
59
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 55
def class_methods_module_uncached
a_module.const_get(CLASS_METHODS_MODULE_NAME)
rescue NameError
nil
end
|
#instance_methods_module_uncached ⇒ Object
61
62
63
64
65
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 61
def instance_methods_module_uncached
a_module.const_get(INSTANCE_METHODS_MODULE_NAME)
rescue NameError
nil
end
|
31
32
33
34
35
36
37
38
39
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 31
def run
setup = self
a_module.extend(::ActiveSupport::Concern)
a_module.included do
%w[class_methods instance_methods after_callback].each do |suffix|
setup.send("setup_#{suffix}", self)
end
end
end
|
#setup_after_callback(base) ⇒ Object
49
50
51
52
53
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 49
def setup_after_callback(base)
common_constructor.after_callback.if_present do |v|
base.instance_eval(&v)
end
end
|
#setup_class_methods(base) ⇒ Object
41
42
43
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 41
def setup_class_methods(base)
class_methods_module.if_present { |v| base.extend v }
end
|
#setup_instance_methods(base) ⇒ Object
45
46
47
|
# File 'lib/eac_ruby_utils/common_concern.rb', line 45
def setup_instance_methods(base)
instance_methods_module.if_present { |v| base.include v }
end
|