Sha256: c702aacc673162d4b924035b772706379a44654f81529e5a0387990bde766c1d
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
module ContextR module PublicApi # allows the explicit activation of layers within a block context # # ContextR::with_layers(:foo, :bar) do # ContextR::active_layers # => [:default, :foo, :bar] # # ContextR::with_layers(:baz) do # ContextR::active_layers # => [:default, :foo, :bar, :baz] # end # # end # # :call-seq: # with_layers(layer_name, ...) { ... } # def with_layers(*layer_symbols, &block) layers = layer_symbols.collect do |layer_symbol| layer_by_symbol(layer_symbol) end layered_do(active_layers_as_classes - layers + layers, block) end alias with_layer with_layers # allows the explicit deactivation of layers within a block context # # ContextR::with_layers(:foo, :bar) do # ContextR::active_layers # => [:default, :foo, :bar] # # ContextR::without_layers(:foo) do # ContextR::active_layers # => [:default, :bar] # end # # end # # :call-seq: # without_layers(layer_name, ...) { ... } # def without_layers(*layer_symbols, &block) layers = layer_symbols.collect do |layer_symbol| layer_by_symbol(layer_symbol) end layered_do(active_layers_as_classes - layers, block) end alias without_layer without_layers # returns all currently active layers in their activation order def active_layers active_layers_as_classes.collect { |layer| symbol_by_layer(layer) } end # returns all layers that where defined, but are not neccessarily active def layers layers_as_classes.collect { |layer| symbol_by_layer(layer) } end end self.extend(PublicApi) end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
contextr-0.1.1 | lib/contextr/public_api.rb |
contextr-0.1.9 | lib/contextr/public_api.rb |