m9t 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/m9t.rb +1 -1
- data/lib/m9t/base.rb +17 -3
- metadata +2 -2
data/lib/m9t.rb
CHANGED
data/lib/m9t/base.rb
CHANGED
@@ -6,9 +6,18 @@ module M9t
|
|
6
6
|
|
7
7
|
module Base
|
8
8
|
|
9
|
-
def self.
|
9
|
+
def self.add_options(klass)
|
10
|
+
|
11
|
+
klass.instance_eval do
|
12
|
+
|
13
|
+
# Make sure derived classes get the extra methods
|
14
|
+
def inherited(sub) #:nodoc:
|
15
|
+
sub.instance_eval do
|
16
|
+
M9t::Base.add_options(sub)
|
17
|
+
end
|
18
|
+
puts "New subclass: #{sub}"
|
19
|
+
end
|
10
20
|
|
11
|
-
base.instance_eval do
|
12
21
|
# Returns the classes current options - see the specific class for defaults
|
13
22
|
def options
|
14
23
|
@options
|
@@ -20,7 +29,7 @@ module M9t
|
|
20
29
|
end
|
21
30
|
|
22
31
|
# The name used for i18n translations
|
23
|
-
#
|
32
|
+
# M9t::Distance => 'distance'
|
24
33
|
def measurement_name
|
25
34
|
name.downcase.split('::')[1]
|
26
35
|
end
|
@@ -30,6 +39,11 @@ module M9t
|
|
30
39
|
|
31
40
|
end
|
32
41
|
|
42
|
+
# Adds methods for handling options
|
43
|
+
def self.included(base) #:nodoc:
|
44
|
+
M9t::Base.add_options(base)
|
45
|
+
end
|
46
|
+
|
33
47
|
attr_reader :value, :options
|
34
48
|
|
35
49
|
# ==== Parameters
|