Class: EacRubyUtils::RequireSub::SubFile
- Defined in:
- lib/eac_ruby_utils/require_sub.rb
Instance Attribute Summary collapse
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #base_constant ⇒ Object
- #constant_name ⇒ Object
- #include_module ⇒ Object
- #include_or_prepend_method ⇒ Object
-
#initialize(owner, path) ⇒ SubFile
constructor
A new instance of SubFile.
- #module? ⇒ Boolean
- #require_file ⇒ Object
Constructor Details
#initialize(owner, path) ⇒ SubFile
70 71 72 73 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 70 def initialize(owner, path) @owner = owner @path = path end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
68 69 70 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 68 def owner @owner end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
68 69 70 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 68 def path @path end |
Instance Method Details
#base_constant ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 75 def base_constant return nil unless owner.base? owner.base.const_get(constant_name) rescue ::NameError nil end |
#constant_name ⇒ Object
83 84 85 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 83 def constant_name ::ActiveSupport::Inflector.camelize(::File.basename(path, '.rb')) end |
#include_module ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 87 def include_module return unless module? owner.include_or_prepend_method.if_present do |v| owner.base.send(v, base_constant) end end |
#include_or_prepend_method ⇒ Object
95 96 97 98 99 100 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 95 def include_or_prepend_method return :include if owner.[OPTION_INCLUDE_MODULES] return :prepend if owner.[OPTION_PREPEND_MODULES] nil end |
#module? ⇒ Boolean
102 103 104 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 102 def module? base_constant.is_a?(::Module) && !base_constant.is_a?(::Class) end |
#require_file ⇒ Object
106 107 108 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 106 def require_file active_support_require || autoload_require || kernel_require end |