tsalzer-typesafe 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -30,7 +30,7 @@ module TypeSafe
30
30
  # this class or object must be kind of a given class.
31
31
  # Method returns <tt>self</tt> unless it raises a TypeError.
32
32
  def must_be_kind_of(clss, &blk)
33
- if clss.kind_of?(Module) or clss.kind_of?(Class)
33
+ if clss.kind_of?(Class)
34
34
  matched = if self.kind_of?(Class)
35
35
  # classes are expected to "descend" from comparator
36
36
  if self != clss
@@ -50,6 +50,15 @@ module TypeSafe
50
50
  raise TypeError.new("#{self} must be of type #{clss}")
51
51
  end
52
52
  end
53
+ elsif clss.kind_of?(Module)
54
+ # check if the given module is included
55
+ unless self.included_modules.include?(clss)
56
+ if blk
57
+ return yield self.class
58
+ else
59
+ raise TypeError.new("#{self} does not include module #{clss}")
60
+ end
61
+ end
53
62
  else
54
63
  raise "class to check #{self} for must be a Class or Module, but is #{clss}"
55
64
  end
@@ -12,6 +12,7 @@ end
12
12
 
13
13
  # plain module
14
14
  module ModA
15
+ def moda_method ; end
15
16
  end
16
17
  # plain class
17
18
  class ClassA
@@ -24,7 +25,7 @@ class ClassC
24
25
  extend ModA
25
26
  end
26
27
  # plain class, includes module ModA, thereby not descending ModA
27
- class Classd
28
+ class ClassD
28
29
  include ModA
29
30
  end
30
31
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{typesafe}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Till Salzer"]
12
- s.date = %q{2009-08-26}
12
+ s.date = %q{2009-08-30}
13
13
  s.description = %q{Simplifies typesafe development by providing the additional
14
14
  methods Object#must_by_kind_of ad Object#must_be_a.}
15
15
  s.email = %q{till.salzer@googlemail.com}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tsalzer-typesafe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Till Salzer
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-26 00:00:00 -07:00
12
+ date: 2009-08-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency