Permalink
Browse files

refactoring "after" implementation to use "before"

  • Loading branch information...
1 parent b5646a3 commit 370c0d12c6a8db326d6bc32b679fd9fa8a990e02 @moonmaster9000 committed Aug 22, 2012
Showing with 2 additions and 27 deletions.
  1. +1 −18 lib/frill/frill.rb
  2. +1 −9 spec/frill_spec.rb
View
@@ -32,7 +32,7 @@ def before decorator
end
def after decorator
- Frill.list.move_after self, decorator
+ Frill.list.move_before decorator, self
end
end
@@ -54,15 +54,6 @@ def move_before label1, label2
detect_cycles
end
- def move_after label1, label2
- node1 = add label1
- node2 = add label2
-
- node1.move_after node2
-
- detect_cycles
- end
-
def [](label)
@nodes[label]
end
@@ -133,14 +124,6 @@ def move_before node
next_node.previous = previous_node
end
- def move_after node
- previous_node = node.last
- first_node = first
-
- previous_node.next = first_node
- first_node.previous = previous_node
- end
-
def first
node = nil
current_node = self
View
@@ -130,17 +130,9 @@ module Module3; include Frill; end
g = Frill::List.new
g.move_before "a", "b"
g.move_before "c", "d"
- g.move_after "b", "c"
+ g.move_before "c", "b"
g.to_a.should == ["c", "d", "a", "b"]
end
- end
-
- describe "#move_after(label1, label2)" do
- it "should move label1 after label2" do
- g = Frill::List.new
- g.move_after "a", "b"
- g.to_a.should == ["b", "a"]
- end
it "should throw exceptions when cycles are detected" do
g = Frill::List.new

0 comments on commit 370c0d1

Please sign in to comment.