Skip to content

Commit

Permalink
Use main.using for ruby 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
k-tsj committed Feb 7, 2015
1 parent 126f1e6 commit 226ad2f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Expand Up @@ -16,10 +16,6 @@ matrix:
env: TEST="test/test_*"
- rvm: 1.9.3
env: TEST="test/test_standard.rb"
- rvm: 2.0.0
env: TEST="test/test_*"
- rvm: 2.0.0
env: TEST="test/test_standard.rb"
- rvm: jruby-19mode
env: TEST="test/test_*"
- rvm: jruby-19mode
Expand Down
6 changes: 2 additions & 4 deletions lib/pattern-match/core.rb
@@ -1,5 +1,7 @@
require 'pattern-match/deconstructor'

using PatternMatch if respond_to?(:using, true)

module PatternMatch
module HasOrderedSubPatterns
private
Expand Down Expand Up @@ -200,8 +202,6 @@ class PatternDeconstructor < PatternElement
class PatternObjectDeconstructor < PatternDeconstructor
include HasOrderedSubPatterns

using PatternMatch if respond_to?(:using, true)

def initialize(deconstructor, *subpatterns)
super(*subpatterns)
@deconstructor = deconstructor
Expand Down Expand Up @@ -524,8 +524,6 @@ def _(*vals)
when 0
uscore = PatternVariable.new(:_)
class << uscore
using PatternMatch if respond_to?(:using, true)

def [](*args)
Array.(*args)
end
Expand Down
6 changes: 4 additions & 2 deletions lib/pattern-match/deconstructor.rb
Expand Up @@ -8,10 +8,12 @@ def pattern_matcher(*subpatterns)
PatternObjectDeconstructor.new(self, *subpatterns)
end
end
end

module Deconstructable
using PatternMatch if respond_to?(:using, true)
using PatternMatch if respond_to?(:using, true)

module PatternMatch
module Deconstructable
def call(*subpatterns)
pattern_matcher(*subpatterns)
end
Expand Down
6 changes: 2 additions & 4 deletions lib/pattern-match/experimental.rb
Expand Up @@ -4,6 +4,8 @@

raise LoadError, 'Module#prepend required' unless Module.respond_to?(:prepend, true)

using PatternMatch if respond_to?(:using, true)

module PatternMatch
class Pattern
module Backtrackable
Expand Down Expand Up @@ -50,8 +52,6 @@ def restore_choice_point
end

module Deconstructable
using PatternMatch if respond_to?(:using, true)

remove_method :call
def call(*subpatterns)
if Object == self
Expand Down Expand Up @@ -180,8 +180,6 @@ class Hash
end

class Object
using PatternMatch if respond_to?(:using, true)

def assert_pattern(pattern)
match(self) do
Kernel.eval("with(#{pattern}) { self }", Kernel.binding)
Expand Down

0 comments on commit 226ad2f

Please sign in to comment.