class GeoserverMigrations::LayergroupConfig

Attributes

options[RW]

Public Class Methods

new(layer_name, is_update_style=false) click to toggle source
# File lib/geoserver_migrations/layergroup_config.rb, line 6
def initialize(layer_name, is_update_style=false)
  @options = {
      layer_name: layer_name,
      is_update_style: is_update_style,
      layers: []
  }
end

Public Instance Methods

layers(*received_layers) click to toggle source
# File lib/geoserver_migrations/layergroup_config.rb, line 19
def layers(*received_layers)
  if received_layers.nil?
    @options[:layers]
  else
    if received_layers.is_a? String
      @options[:layers] = received_layers.split(/[,; ]/).select{|x| !x.empty?}
    elsif received_layers.is_a? Array
      received_layers.each do |received_layer|
        @options[:layers] += received_layer.split(/[,; ]/).select{|x| !x.empty?}
      end   
    end           
  end
end
method_missing(method,*args,&block) click to toggle source
Calls superclass method
# File lib/geoserver_migrations/layergroup_config.rb, line 33
def method_missing(method,*args,&block)
  # puts "LayerConfig method-missing: #{method.inspect}, #{args.inspect}"
  if [:layer_name].include? method.to_sym
    if args.size > 0
      value = args.size == 1 ? args.first : args
      value = value.strip if value.is_a? String
      @options[method.to_sym] = value
    else
      @options[method.to_sym]
    end
  else
    super
  end
end
valid?() click to toggle source
# File lib/geoserver_migrations/layergroup_config.rb, line 14
def valid?
  # at least one layer to be grouped should be present?
  options[:layers].size > 0
end