Class: Schienenzeppelin::AddOn

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Actions, Rails::Generators::AppName, Thor::Actions
Defined in:
lib/schienenzeppelin/add_on.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ AddOn

Returns a new instance of AddOn.



11
12
13
14
15
# File 'lib/schienenzeppelin/add_on.rb', line 11

def initialize(context)
  super
  @context = context
  @dependencies = self.class.dependencies || []
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



9
10
11
# File 'lib/schienenzeppelin/add_on.rb', line 9

def context
  @context
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



9
10
11
# File 'lib/schienenzeppelin/add_on.rb', line 9

def dependencies
  @dependencies
end

Class Method Details

.apply(context = Context.new({})) ⇒ Object



41
42
43
44
45
46
# File 'lib/schienenzeppelin/add_on.rb', line 41

def apply(context = Context.new({}))
  instance = new(context)
  return unless instance.uses?

  instance.apply
end

.default_source_rootObject



37
38
39
# File 'lib/schienenzeppelin/add_on.rb', line 37

def default_source_root
  File.expand_path(File.join('..', '..', 'templates'), __dir__)
end

.dependenciesObject



57
58
59
# File 'lib/schienenzeppelin/add_on.rb', line 57

def dependencies
  @dependencies ||= []
end

.get(addon) ⇒ Object



48
49
50
51
# File 'lib/schienenzeppelin/add_on.rb', line 48

def get(addon)
  addon = addon.to_s.capitalize.camelize
  "Schienenzeppelin::AddOns::#{addon}".constantize
end

.identifierObject



53
54
55
# File 'lib/schienenzeppelin/add_on.rb', line 53

def identifier
  name.demodulize.underscore.to_sym
end

Instance Method Details

#applyObject



17
# File 'lib/schienenzeppelin/add_on.rb', line 17

def apply; end