acts_as_crazy 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/acts_as_crazy.rb +7 -1
- data/lib/acts_as_crazy/configuration.rb +20 -0
- data/lib/acts_as_crazy/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce0de34217da7dbbf4cecd2aa90f0fd24931aa57850148ed8aeea1447c3fead7
|
4
|
+
data.tar.gz: d116fe666786d0cc7b4229cf48537304331ac3459d1c155907dfcc3aa6c04d09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4286f5d77f2b46e4d12ff2894c82e9fe933a2d3fa0424b617bb37be60f655abfb3edbf92302274316328d3a369a7e880737e8ddcb0a4ec6fd08e0d0085b56a3
|
7
|
+
data.tar.gz: 16e0c5cc24ef37b8f75639ff069eeb118ad071c8517c560fb59156d0fbf238e253b3634daa6811f694e8c184439c7272ca4ef12fb968ef778e69366a1365f200
|
data/Gemfile.lock
CHANGED
data/lib/acts_as_crazy.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
require "acts_as_crazy/version"
|
2
2
|
require "acts_as_crazy/crazy"
|
3
|
-
|
3
|
+
require "acts_as_crazy/configuration"
|
4
4
|
|
5
5
|
module ActsAsCrazy
|
6
6
|
class << self
|
7
7
|
attr_accessor :configuration
|
8
|
+
|
9
|
+
def configure
|
10
|
+
self.configuration ||= Configuration.new
|
11
|
+
yield(configuration)
|
12
|
+
end
|
8
13
|
end
|
9
14
|
|
10
15
|
class Error < StandardError; end
|
11
16
|
class CrazyError < StandardError; end
|
17
|
+
class WrongCrazinessError < StandardError; end
|
12
18
|
end
|
13
19
|
|
14
20
|
Object.class_eval do
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActsAsCrazy
|
2
|
+
class Configuration
|
3
|
+
attr_reader :craziness_level
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@craziness_level = 50
|
7
|
+
end
|
8
|
+
|
9
|
+
def craziness_level=(level)
|
10
|
+
raise WrongCrazinessError.new("craziness must be between 0 and 100") unless good_craziness_level?(level)
|
11
|
+
@craziness_level = level.to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def good_craziness_level?(level)
|
17
|
+
level >= 0 && level <= 100
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|