Class: EacRubyUtils::CommonConcern::ClassSetup
- Includes:
- Memoized
- Defined in:
- lib/eac_ruby_utils/common_concern/class_setup.rb
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
-
#initialize(module_setup, a_class, include_method) ⇒ ClassSetup
constructor
A new instance of ClassSetup.
- #run ⇒ Object
- #setup_after_callback ⇒ Object
- #setup_class_methods ⇒ Object
- #setup_instance_methods ⇒ Object
Constructor Details
#initialize(module_setup, a_class, include_method) ⇒ ClassSetup
Returns a new instance of ClassSetup.
14 15 16 17 18 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 14 def initialize(module_setup, a_class, include_method) @module_setup = module_setup @a_class = a_class @include_method = include_method end |
Instance Attribute Details
#a_class ⇒ Object (readonly)
Returns the value of attribute a_class.
12 13 14 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 12 def a_class @a_class end |
#include_method ⇒ Object (readonly)
Returns the value of attribute include_method.
12 13 14 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 12 def include_method @include_method end |
#module_setup ⇒ Object (readonly)
Returns the value of attribute module_setup.
12 13 14 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 12 def module_setup @module_setup end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 20 def run %w[class_methods instance_methods after_callback].each do |suffix| send("setup_#{suffix}") end end |
#setup_after_callback ⇒ Object
34 35 36 37 38 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 34 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
26 27 28 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 26 def setup_class_methods class_methods_module.if_present { |v| a_class.extend v } end |
#setup_instance_methods ⇒ Object
30 31 32 |
# File 'lib/eac_ruby_utils/common_concern/class_setup.rb', line 30 def setup_instance_methods instance_methods_module.if_present { |v| a_class.send(include_method, v) } end |