class Schienenzeppelin::AddOn
Attributes
context[R]
dependencies[R]
Public Class Methods
apply(context = Context.new({}))
click to toggle source
# 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_root()
click to toggle source
# File lib/schienenzeppelin/add_on.rb, line 37 def default_source_root File.expand_path(File.join('..', '..', 'templates'), __dir__) end
dependencies()
click to toggle source
# File lib/schienenzeppelin/add_on.rb, line 57 def dependencies @dependencies ||= [] end
get(addon)
click to toggle source
# File lib/schienenzeppelin/add_on.rb, line 48 def get(addon) addon = addon.to_s.capitalize.camelize "Schienenzeppelin::AddOns::#{addon}".constantize end
identifier()
click to toggle source
# File lib/schienenzeppelin/add_on.rb, line 53 def identifier name.demodulize.underscore.to_sym end
new(context)
click to toggle source
Calls superclass method
# File lib/schienenzeppelin/add_on.rb, line 11 def initialize(context) super @context = context @dependencies = self.class.dependencies || [] end
Protected Class Methods
depends_on(*addon)
click to toggle source
# File lib/schienenzeppelin/add_on.rb, line 63 def depends_on(*addon) @dependencies = addon.map(&:to_sym) end
Public Instance Methods
apply()
click to toggle source
# File lib/schienenzeppelin/add_on.rb, line 17 def apply; end
options()
click to toggle source
# File lib/schienenzeppelin/add_on.rb, line 20 def options @context.options end
uses?(identifier = nil)
click to toggle source
# File lib/schienenzeppelin/add_on.rb, line 24 def uses?(identifier = nil) identifier ||= self.class.identifier options = @context.options return false if options["skip_#{identifier}".to_sym] return true if @context.default_addons.include?(identifier) clazz = identifier.nil? ? self.class : self.class.get(identifier) Dependencies.new(clazz, @context).satisfied? end