class AxR::App
Constants
- LayerConflictError
Attributes
default_options[R]
layers[R]
Public Class Methods
new()
click to toggle source
# File lib/axr/app.rb, line 15 def initialize @layers = [] end
Public Instance Methods
define(default_options = {}, &block)
click to toggle source
# File lib/axr/app.rb, line 19 def define(default_options = {}, &block) @default_options = default_options instance_eval(&block) end
layer(layer_name, options = {})
click to toggle source
# File lib/axr/app.rb, line 24 def layer(layer_name, options = {}) check_name_conflict!(layer_name) layers << AxR::Layer.new(layer_name, layers.size, default_options.merge(options)) end
layer_names()
click to toggle source
# File lib/axr/app.rb, line 30 def layer_names layers.map(&:name).map(&:to_s) end
legal?(context, dependncy)
click to toggle source
rubocop:disable Metrics/AbcSize rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity
# File lib/axr/app.rb, line 37 def legal?(context, dependncy) ctx = layers.find { |l| l.name.to_s == context.to_s } dep = layers.find { |l| l.name.to_s == dependncy.to_s } return false unless ctx && dep return false if ctx.isolated? && ctx.familiar_with.empty? return true if ctx.familiar_with.map(&:to_s).include?(dependncy.to_s) ctx.level < dep.level end
Private Instance Methods
check_name_conflict!(layer_name)
click to toggle source
rubocop:enable Metrics/AbcSize rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity
# File lib/axr/app.rb, line 53 def check_name_conflict!(layer_name) return unless layers.map(&:name).include?(layer_name) raise LayerConflictError, "Layer #{layer_name} is already defined in the app" end
reset()
click to toggle source
Use only for testing purpose!
# File lib/axr/app.rb, line 60 def reset @layers = [] end