hairy_dangerzone 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -17,28 +17,27 @@ Or install it yourself as:
17
17
  $ gem install hairy_dangerzone
18
18
 
19
19
  ## Usage
20
+
20
21
  ```ruby
21
- class MyClass
22
- include HairyDangerzone::Awesome
23
-
24
- danger_danger :x, "Not a string" do |attr|
25
- attr.is_a?(String)
26
- end
27
- end
28
-
29
- # spec
30
- i = MyClass.new
31
- i.x = "ok"
32
- i.x = 1 #=> should raise "Invalid String"
33
- =end
34
-
35
- # spec 2
36
- i.hairy_dangerzone_x?(1) #=> false
37
- i.hairy_dangerzone_x?("Hello") #=> true
22
+ class MyClass
23
+ include HairyDangerzone::Awesome
24
+
25
+ danger_danger :x, "Not a string" do |attr|
26
+ attr.is_a?(String)
27
+ end
28
+ end
29
+
30
+ i = MyClass.new
31
+ i.x = "ok"
32
+ i.x = 1 #=> should raise "Invalid String"
33
+
34
+ i.hairy_dangerzone_x?(1) #=> false
35
+ i.hairy_dangerzone_x?("Hello") #=> true
38
36
  ```
37
+
39
38
  ## Contributing
40
39
 
41
- 1. Fork it ( http://github.com/<my-github-username>/hairy_dangerzone/fork )
40
+ 1. Fork it ( http://github.com/iamteem/hairy_dangerzone/fork )
42
41
  2. Create your feature branch (`git checkout -b my-new-feature`)
43
42
  3. Commit your changes (`git commit -am 'Add some feature'`)
44
43
  4. Push to the branch (`git push origin my-new-feature`)
@@ -8,18 +8,16 @@ module HairyDangerzone
8
8
 
9
9
  module ClassMethods
10
10
  def danger_danger(attribute, fail_message, &block)
11
- self.instance_eval do
12
- define_method :"#{attribute}_with_danger_danger=" do |new_value|
13
- if block.call(new_value)
14
- send(:"#{attribute}_without_danger_danger=", new_value)
15
- else
16
- fail fail_message
17
- end
11
+ define_method :"#{attribute}_with_danger_danger=" do |new_value|
12
+ if block.call(new_value)
13
+ send(:"#{attribute}_without_danger_danger=", new_value)
14
+ else
15
+ fail fail_message
18
16
  end
19
-
20
- alias_method :"#{attribute}_without_danger_danger=", :"#{attribute}="
21
- alias_method :"#{attribute}=", :"#{attribute}_with_danger_danger="
22
17
  end
18
+
19
+ alias_method :"#{attribute}_without_danger_danger=", :"#{attribute}="
20
+ alias_method :"#{attribute}=", :"#{attribute}_with_danger_danger="
23
21
  end
24
22
  end
25
23
  end
@@ -1,3 +1,3 @@
1
1
  module HairyDangerzone
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hairy_dangerzone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: