Class: EacRubyUtils::RequireSub::SubFile
- Defined in:
- lib/eac_ruby_utils/require_sub/sub_file.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
-
#initialize(owner, path) ⇒ SubFile
constructor
A new instance of SubFile.
- #module? ⇒ Boolean
- #require_file ⇒ Object
Constructor Details
#initialize(owner, path) ⇒ SubFile
Returns a new instance of SubFile.
11 12 13 14 |
# File 'lib/eac_ruby_utils/require_sub/sub_file.rb', line 11 def initialize(owner, path) @owner = owner @path = path end |
Instance Attribute Details
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
9 10 11 |
# File 'lib/eac_ruby_utils/require_sub/sub_file.rb', line 9 def owner @owner end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/eac_ruby_utils/require_sub/sub_file.rb', line 9 def path @path end |
Instance Method Details
#base_constant ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/eac_ruby_utils/require_sub/sub_file.rb', line 16 def base_constant return nil unless owner.base? owner.base.const_get(constant_name) rescue ::NameError nil end |
#constant_name ⇒ Object
24 25 26 |
# File 'lib/eac_ruby_utils/require_sub/sub_file.rb', line 24 def constant_name ::ActiveSupport::Inflector.camelize(::File.basename(path, '.rb')) end |
#include_module ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/eac_ruby_utils/require_sub/sub_file.rb', line 28 def include_module return unless module? owner.include_or_prepend_method.if_present do |v| owner.base.send(v, base_constant) end end |
#module? ⇒ Boolean
36 37 38 |
# File 'lib/eac_ruby_utils/require_sub/sub_file.rb', line 36 def module? base_constant.is_a?(::Module) && !base_constant.is_a?(::Class) end |
#require_file ⇒ Object
40 41 42 |
# File 'lib/eac_ruby_utils/require_sub/sub_file.rb', line 40 def require_file send("#{owner.require_mode}_require") end |