Class: Schienenzeppelin::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/schienenzeppelin/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Context

Returns a new instance of Context.



7
8
9
10
# File 'lib/schienenzeppelin/context.rb', line 7

def initialize(options = {})
  @options = options
  @callbacks = []
end

Instance Attribute Details

#callbacksObject (readonly)

Returns the value of attribute callbacks.



5
6
7
# File 'lib/schienenzeppelin/context.rb', line 5

def callbacks
  @callbacks
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/schienenzeppelin/context.rb', line 5

def options
  @options
end

Instance Method Details

#addonsObject



12
13
14
15
16
17
# File 'lib/schienenzeppelin/context.rb', line 12

def addons
  AddOns.constants
    .select { |clazz| AddOns.const_get(clazz).is_a?(Class) }
    .map(&:name)
    .map(&:underscore)
end

#default_addonsObject

Skippable parts of the default Rails generator, e.g. active_record, active_job…



20
21
22
23
24
# File 'lib/schienenzeppelin/context.rb', line 20

def default_addons
  addon_options = addons.map { |option| "skip_#{option}".to_sym }
  skip_options = Schienenzeppelin::AppGenerator.class_options.keys.select { |key| key =~ /skip_/ }
  (skip_options - addon_options).map { |option| option.to_s.delete_prefix('skip_').to_sym }
end