Class: GeoserverMigrations::LayergroupConfig
- Inherits:
-
Object
- Object
- GeoserverMigrations::LayergroupConfig
- Defined in:
- lib/geoserver_migrations/layergroup_config.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(layer_name, is_update_style = false) ⇒ LayergroupConfig
constructor
A new instance of LayergroupConfig.
- #layers(*received_layers) ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(layer_name, is_update_style = false) ⇒ LayergroupConfig
Returns a new instance of LayergroupConfig.
6 7 8 9 10 11 12 |
# 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 |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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 |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4 5 6 |
# File 'lib/geoserver_migrations/layergroup_config.rb', line 4 def @options end |
Instance Method Details
#layers(*received_layers) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 |
#valid? ⇒ Boolean
14 15 16 17 |
# File 'lib/geoserver_migrations/layergroup_config.rb', line 14 def valid? # at least one layer to be grouped should be present? [:layers].size > 0 end |