Sha256: 664b926747ee76e5bfa2b8d1883bd3bbd8080872c1bb9346228fe891c807b901

Contents?: true

Size: 1.91 KB

Versions: 17

Compression:

Stored size: 1.91 KB

Contents

#
# Manage a list of methods to be included or excluded.  This allows fine
# grained control over filters.
#

module Ruby2JS
  module Filter

    #
    # module level defaults
    #

    @@included = nil
    @@excluded = []

    # indicate that the specified methods are not to be processed
    def self.exclude(*methods)
      if @@included
        @@included -= methods.flatten
      else
        @@excluded += methods.flatten
      end
    end

    # indicate that all methods are to be processed
    def self.include_all
      @@included = nil
      @@excluded = []
    end

    # indicate that only the specified methods are to be processed
    def self.include_only(*methods)
      @@included = methods.flatten
    end

    # indicate that the specified methods are to be processed
    def self.include(*methods)
      if @@included
        @@included += methods.flatten
      else
        @@excluded -= methods.flatten
      end
    end

    #
    # instance level overrides
    #

    # determine if a method is NOT to be processed
    def excluded?(method)
      if @included
        not @included.include? method
      else
        return true if @exclude_methods.flatten.include? method
        @excluded.include? method
      end
    end

    # indicate that all methods are to be processed
    def include_all
      @included = nil
      @excluded = []
    end

    # indicate that only the specified methods are to be processed
    def include_only(*methods)
      @included = methods.flatten
    end

    # indicate that the specified methods are to be processed
    def include(*methods)
      if @included
        @included += methods.flatten
      else
        @excluded -= methods.flatten
      end
    end

    # indicate that the specified methods are not to be processed
    def exclude(*methods)
      if @included
        @included -= methods.flatten
      else
        @excluded += methods.flatten
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
ruby2js-3.6.1 lib/ruby2js/filter.rb
ruby2js-3.6.0 lib/ruby2js/filter.rb
ruby2js-3.5.3 lib/ruby2js/filter.rb
ruby2js-3.5.2 lib/ruby2js/filter.rb
ruby2js-3.5.1 lib/ruby2js/filter.rb
ruby2js-3.5.0 lib/ruby2js/filter.rb
ruby2js-3.4.0 lib/ruby2js/filter.rb
ruby2js-3.3.6 lib/ruby2js/filter.rb
ruby2js-3.3.5 lib/ruby2js/filter.rb
ruby2js-3.3.4 lib/ruby2js/filter.rb
ruby2js-3.3.3 lib/ruby2js/filter.rb
ruby2js-3.3.2 lib/ruby2js/filter.rb
ruby2js-3.3.1 lib/ruby2js/filter.rb
ruby2js-3.3.0 lib/ruby2js/filter.rb
ruby2js-3.2.0 lib/ruby2js/filter.rb
ruby2js-3.1.2 lib/ruby2js/filter.rb
ruby2js-3.1.1 lib/ruby2js/filter.rb