Commit f737e618 authored by Rene Saarsoo's avatar Rene Saarsoo
Browse files

Enhance #find_memembers to allow for exclusion of static members.

Like with old #get_members the :static option can be true, false or nil.
With :static=>false only non-static members are returned.
parent 9ccbc6f6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -337,8 +337,10 @@ module JsDuck
        ms = ms.find_all {|m| m[:tagname] == query[:tagname] }
      end

      if query[:static]
      if query[:static] == true
        ms = ms.find_all {|m| m[:meta] && m[:meta][:static] }
      elsif query[:static] == false
        ms = ms.reject {|m| m[:meta] && m[:meta][:static] }
      end

      ms
+9 −1
Original line number Diff line number Diff line
@@ -71,10 +71,14 @@ describe JsDuck::Class do
      cls.find_members(:tagname => :cfg).length.should == 0
    end

    it "finds no statics when there are no static members" do
    it "finds no members when :static => true specified" do
      cls.find_members(:static => true).length.should == 0
    end

    it "finds all members when :static => false specified" do
      cls.find_members(:static => false).length.should == 6
    end

    it "finds member in itself" do
      cls.find_members(:name => "inChild").length.should == 1
    end
@@ -162,6 +166,10 @@ describe JsDuck::Class do
    it "finds all static members" do
      cls.find_members(:static => true).length.should == 4
    end

    it "finds no static members when :static=>false specified" do
      cls.find_members(:static => false).length.should == 0
    end
  end

  describe "when #find_members called before" do