Class: GeoserverMigrations::LayerConfig
- Inherits:
-
Object
- Object
- GeoserverMigrations::LayerConfig
- Includes:
- SldHelpers
- Defined in:
- lib/geoserver_migrations/layer_config.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
attr_writer :sld, :layer_name, :feature_name, :style_name.
Instance Method Summary collapse
-
#initialize(layer_name, is_update_style = false) ⇒ LayerConfig
constructor
A new instance of LayerConfig.
- #method_missing(method, *args, &block) ⇒ Object
- #style_name(style_name = nil) ⇒ Object
- #valid? ⇒ Boolean
Methods included from SldHelpers
#build_sld_filter, #icon_style_with_label, #line_style, #polygon_style
Constructor Details
#initialize(layer_name, is_update_style = false) ⇒ LayerConfig
Returns a new instance of LayerConfig.
9 10 11 12 13 14 15 |
# File 'lib/geoserver_migrations/layer_config.rb', line 9 def initialize(layer_name, is_update_style=false) @options = { layer_name: layer_name, is_update_style: is_update_style } end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/geoserver_migrations/layer_config.rb', line 32 def method_missing(method,*args,&block) # puts "LayerConfig method-missing: #{method.inspect}, #{args.inspect}" if [:sld, :layer_name, :feature_name, :style_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
attr_writer :sld, :layer_name, :feature_name, :style_name
7 8 9 |
# File 'lib/geoserver_migrations/layer_config.rb', line 7 def @options end |
Instance Method Details
#style_name(style_name = nil) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/geoserver_migrations/layer_config.rb', line 24 def style_name(style_name=nil) if style_name.nil? @options[:style_name] || @options[:layer_name] else @options[:style_name] = style_name end end |
#valid? ⇒ Boolean
19 20 21 22 |
# File 'lib/geoserver_migrations/layer_config.rb', line 19 def valid? # at least feature-name should be present? [:feature_name].present? || ([:is_update_style] && [:sld].present?) end |