reallycare_utils 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,7 +16,7 @@ module ReallycareUtils
16
16
  end
17
17
 
18
18
  define_method("has_#{attribute}_#{value_name}?".to_sym) do
19
- (self["#{attribute}"][i] || 0) != 0
19
+ ((self["#{attribute}"] || 0 )[i]) != 0
20
20
  end
21
21
  end
22
22
 
@@ -34,4 +34,45 @@ module ReallycareUtils
34
34
  end
35
35
  end
36
36
 
37
+ if __FILE__ == $0
37
38
 
39
+ class FakeActiveRecord
40
+ def [](value)
41
+ instance_variable_get(('@'+value).to_sym)
42
+ end
43
+
44
+ def []=(value, value2)
45
+ instance_variable_set(('@'+value).to_sym, value2)
46
+ end
47
+ end
48
+
49
+ class User < FakeActiveRecord
50
+ include ReallycareUtils::Bitmask
51
+
52
+ has_bitmasks :status => [:verified, :locked_out], :role => [:admin, :staff]
53
+ end
54
+
55
+ class Angel < FakeActiveRecord
56
+ include ReallycareUtils::Bitmask
57
+ has_bitmasks :status => [:pending, :approved]
58
+ end
59
+
60
+ if __FILE__ == $0
61
+ u = User.new
62
+ u.add_status_verified
63
+ puts "#{u.has_role_staff?} should be false" if u.has_role_staff?
64
+ u.add_role_staff
65
+ puts "#{u.show_role_flags} should be staff" unless u.show_role_flags == [:staff]
66
+ puts "#{u.show_status_flags} should be verified" unless u.show_status_flags == [:verified]
67
+ puts "#{u.has_status_verified?} should be true" unless u.has_status_verified?
68
+ puts "#{u.has_status_locked_out?} should be false" if u.has_status_locked_out?
69
+ u.add_status_locked_out
70
+ puts "#{u.show_status_flags} should be verified and locked_out" unless u.show_status_flags == [:verified, :locked_out]
71
+ u.remove_status_verified
72
+ puts "#{u.show_status_flags} should be locked_out" unless u.show_status_flags == [:locked_out]
73
+ a = Angel.new
74
+ a.add_status_pending
75
+ puts "#{a.show_status_flags} should be pending" unless a.show_status_flags == [:pending]
76
+ puts "Success!"
77
+ end
78
+ end
@@ -1,3 +1,3 @@
1
1
  module ReallycareUtils
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reallycare_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: