Sha256: 95e090f8b2ba130213437154168596f6269bdadc326c6ab777c0ecb2aede5f2d
Contents?: true
Size: 1.09 KB
Versions: 11
Compression:
Stored size: 1.09 KB
Contents
module Ixtlan module Babel class Config def initialize( options ) @only = options[ :only ].collect { |o| o.to_s } if options[ :only ] @except = ( options[:except] || [] ).collect { |e| e.to_s } opts = options[ :include ] @include = case opts when Array opts.collect { |i| i.to_s } when Hash Hash[ opts.collect { |k,v| [ k.to_s, v ] } ] else [] end @methods = (options[:methods] || []).collect { |m| m.to_s } end def methods @methods + ( @include.is_a?( Array ) ? @include : @include.keys ) end def allowed?( key ) ( @only && @only.include?( key ) ) || ( @only.nil? && !@except.include?( key ) ) || @methods.include?( key ) end def include?( key ) @include.include? key end def array? @include.is_a?( Array ) end def []( key ) self.class.new( @include.is_a?( Array ) ? {} : @include[ key ] ) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems