Class: EacRubyUtils::RequireSub
- Includes:
- Listable
- Defined in:
- lib/eac_ruby_utils/require_sub.rb
Defined Under Namespace
Classes: SubFile
Constant Summary collapse
- INCLUDE_MODULES_MAP =
{ nil => nil, false => nil, true => :include, include: :include, prepend: :prepend }.freeze
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #apply ⇒ Object
- #base ⇒ Object
- #base? ⇒ Boolean
- #include_modules ⇒ Object
- #include_or_prepend_method ⇒ Object
-
#initialize(file, options = {}) ⇒ RequireSub
constructor
A new instance of RequireSub.
- #require_sub_files ⇒ Object
- #sub_files ⇒ Object
Constructor Details
#initialize(file, options = {}) ⇒ RequireSub
Returns a new instance of RequireSub.
28 29 30 31 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 28 def initialize(file, = {}) @file = file @options = self.class.lists.option.hash_keys_validate!() end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
26 27 28 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 26 def file @file end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
26 27 28 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 26 def @options end |
Instance Method Details
#apply ⇒ Object
33 34 35 36 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 33 def apply require_sub_files include_modules end |
#base ⇒ Object
38 39 40 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 38 def base [OPTION_BASE] || raise('Option :base not setted') end |
#base? ⇒ Boolean
42 43 44 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 42 def base? [OPTION_BASE] ? true : false end |
#include_modules ⇒ Object
46 47 48 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 46 def include_modules sub_files.each(&:include_module) end |
#include_or_prepend_method ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 50 def include_or_prepend_method return INCLUDE_MODULES_MAP.fetch([OPTION_INCLUDE_MODULES]) if INCLUDE_MODULES_MAP.key?([OPTION_INCLUDE_MODULES]) raise ::ArgumentError, "Invalid value for 'options[OPTION_INCLUDE_MODULES]':" \ " \"#{[OPTION_INCLUDE_MODULES]}\"" end |
#require_sub_files ⇒ Object
58 59 60 |
# File 'lib/eac_ruby_utils/require_sub.rb', line 58 def require_sub_files sub_files.each(&:require_file) end |