Class: RKit::Core::Loader::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/r_kit/core/loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base, service:) ⇒ Dependency

Returns a new instance of Dependency.



117
118
119
120
# File 'lib/r_kit/core/loader.rb', line 117

def initialize base, service:;
  @base = base
  @service = RKit.const_get(service.to_s.classify)
end

Instance Attribute Details

#baseObject

Returns the value of attribute base.



115
116
117
# File 'lib/r_kit/core/loader.rb', line 115

def base
  @base
end

#serviceObject

Returns the value of attribute service.



115
116
117
# File 'lib/r_kit/core/loader.rb', line 115

def service
  @service
end

Instance Method Details

#dependency!Object



126
127
128
129
130
131
132
133
# File 'lib/r_kit/core/loader.rb', line 126

def dependency!
  warn %Q{
WARNING - #{ @service.name } was implicitly loaded,
  As a dependency for #{ base }.
  You may want to load it explicitly.
  }
  @service.load
end

#load!Object



135
136
137
# File 'lib/r_kit/core/loader.rb', line 135

def load!
  dependency! if should_load?
end

#should_load?Boolean

Returns:

  • (Boolean)


122
123
124
# File 'lib/r_kit/core/loader.rb', line 122

def should_load?
  !RKit::Core::Loader.class_variable_get(:@@loaded).include? @service.name
end