Loading lib/jsduck/class.rb +5 −0 Original line number Diff line number Diff line Loading @@ -119,12 +119,17 @@ module JsDuck # When nil or unspecified, both static # and instance members are returned. # # - :local : Boolean - true to only return non-inherited members. # # When called without arguments all members are returned. # # When nothing found, an empty array is returned. def find_members(query={}) if query[:name] ms = global_members_hash_by_name[query[:name]] || [] ms = ms.find_all {|m| m[:owner] == @doc[:name]} if query[:local] elsif query[:local] ms = local_members_hash.values else ms = global_members_hash.values end Loading spec/class_spec.rb +16 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,22 @@ describe JsDuck::Class do it "finds overridden mixin member" do cls.find_members(:name => "alsoInMixin")[0][:owner].should == "ChildClass" end it "finds just local members with :local=>true" do cls.find_members(:local => true).length.should == 4 end it "finds a local member if :local=>true" do cls.find_members(:name => "inChild", :local => true).length.should == 1 end it "doesn't find parent member if :local=>true" do cls.find_members(:name => "inParent", :local => true).length.should == 0 end it "doesn't find mixin member if :local=>true" do cls.find_members(:name => "inMixin", :local => true).length.should == 0 end end describe "#find_members with statics" do Loading Loading
lib/jsduck/class.rb +5 −0 Original line number Diff line number Diff line Loading @@ -119,12 +119,17 @@ module JsDuck # When nil or unspecified, both static # and instance members are returned. # # - :local : Boolean - true to only return non-inherited members. # # When called without arguments all members are returned. # # When nothing found, an empty array is returned. def find_members(query={}) if query[:name] ms = global_members_hash_by_name[query[:name]] || [] ms = ms.find_all {|m| m[:owner] == @doc[:name]} if query[:local] elsif query[:local] ms = local_members_hash.values else ms = global_members_hash.values end Loading
spec/class_spec.rb +16 −0 Original line number Diff line number Diff line Loading @@ -99,6 +99,22 @@ describe JsDuck::Class do it "finds overridden mixin member" do cls.find_members(:name => "alsoInMixin")[0][:owner].should == "ChildClass" end it "finds just local members with :local=>true" do cls.find_members(:local => true).length.should == 4 end it "finds a local member if :local=>true" do cls.find_members(:name => "inChild", :local => true).length.should == 1 end it "doesn't find parent member if :local=>true" do cls.find_members(:name => "inParent", :local => true).length.should == 0 end it "doesn't find mixin member if :local=>true" do cls.find_members(:name => "inMixin", :local => true).length.should == 0 end end describe "#find_members with statics" do Loading