Class: RKit::Core::Engineer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base) ⇒ Engineer

Returns a new instance of Engineer.



4
5
6
# File 'lib/r_kit/core/engineer.rb', line 4

def initialize base
  @_base = base
end

Instance Attribute Details

#_baseObject

Returns the value of attribute _base.



2
3
4
# File 'lib/r_kit/core/engineer.rb', line 2

def _base
  @_base
end

#pathnameObject

Returns the value of attribute pathname.



2
3
4
# File 'lib/r_kit/core/engineer.rb', line 2

def pathname
  @pathname
end

#sprocketsObject

Returns the value of attribute sprockets.



2
3
4
# File 'lib/r_kit/core/engineer.rb', line 2

def sprockets
  @sprockets
end

Instance Method Details

#load!Object



38
39
40
41
# File 'lib/r_kit/core/engineer.rb', line 38

def load!
  load_engine! if load_engine?
  load_sprockets! if load_sprockets?
end

#load_engine!Object



13
14
15
16
17
18
19
# File 'lib/r_kit/core/engineer.rb', line 13

def load_engine!
  pathname = @pathname

  Class.new(Rails::Engine) do
    paths.path = pathname
  end
end

#load_engine?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/r_kit/core/engineer.rb', line 9

def load_engine?
  @pathname
end

#load_sprockets!Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/r_kit/core/engineer.rb', line 26

def load_sprockets!
  digest = _base.digest
  sprockets_extend = Module.new do
    define_method 'digest' do
      super().update(digest)
    end
  end

  Sprockets::Base.send :prepend, sprockets_extend
end

#load_sprockets?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/r_kit/core/engineer.rb', line 22

def load_sprockets?
  @sprockets
end