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

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