Module: Typ::Is::Array

Defined in:
lib/typ.rb

Defined Under Namespace

Modules: Singleton

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(gate) ⇒ Object



80
81
82
# File 'lib/typ.rb', line 80

def self.included gate
  gate.extend Singleton
end

.new(array) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/typ.rb', line 58

def new array
  check = if array[0].is_a?(Symbol)
    method, *arguments = array
    -> receiver { receiver.send method, *arguments }
  elsif array[1].is_a?(Symbol)
    receiver, method = array
    -> argument { receiver.send method, argument }
  else
    fail "not sure how to handle #{array} yet"
  end
      
  gate = Class.new
      
  gate.include Is
  gate.check = check
      
  gate.include self
  gate.array = array
  gate
end

Instance Method Details

#to_aObject



88
89
90
# File 'lib/typ.rb', line 88

def to_a
  self.class.array
end