@@ -78,12 +78,17 @@ def initialize(stylesheet, args = {})
7878 @kv [ :source ] ||= stylesheet . sources . find { |_k , v | v [ :default ] } [ 0 ]
7979 @kv [ :source_layer ] ||= args [ :id ] if stylesheet . sources [ @kv [ :source ] ] [ :type ] == 'vector'
8080 @child_num = 0 # incremented sublayer suffix
81+ @dsl = LayerDSL . new ( self )
82+ end
83+
84+ def dsl_eval ( &block )
85+ @dsl . instance_eval ( &block )
8186 end
8287
8388 # Handle all missing 'method' calls
8489 # If we can match it to a GL property, it's an assignment:
8590 # otherwise it's an OSM key
86- def method_missing ( method_sym , *arguments )
91+ def add_property ( method_sym , *arguments )
8792 if EXPRESSIONS . include? ( method_sym )
8893 Condition . new . from_list ( method_sym , arguments )
8994 elsif LAYOUT . include? ( method_sym ) || PAINT . include? ( method_sym ) || TOP_LEVEL . include? ( method_sym )
@@ -135,7 +140,7 @@ def on(*args, &block)
135140 sub_cond = nilsafe_merge ( sub_cond , @condition )
136141 end
137142 r . _set_filter ( nilsafe_merge ( sub_cond , @uncascaded ) )
138- r . instance_eval ( &block )
143+ r . dsl_eval ( &block )
139144 @stylesheet . _add_layer ( r )
140145
141146 # Create cascaded layers
@@ -159,7 +164,7 @@ def nilsafe_merge(a, b) # rubocop:disable Naming/MethodParameterName
159164 def cascade ( *args , &block )
160165 cond = args . length == 1 ? args [ 0 ] : Condition . new . from_list ( :any , args )
161166 @cascade_cond = cond
162- instance_eval ( &block )
167+ dsl_eval ( &block )
163168 @cascade_cond = nil
164169 end
165170
0 commit comments