enumerated_attr 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/enumerated_attr.rb +6 -8
- data/lib/enumerated_attr/version.rb +1 -1
- metadata +4 -4
data/lib/enumerated_attr.rb
CHANGED
@@ -5,7 +5,7 @@ module EnumeratedAttr
|
|
5
5
|
module Base
|
6
6
|
def self.human(klass, attribute, value)
|
7
7
|
klass_name = klass.name.underscore
|
8
|
-
I18n.t
|
8
|
+
I18n.t :"enumerations.#{klass_name}.#{attribute}.#{value}", :default => value.to_s.humanize
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.enumeration(klass, attribute, enumeration)
|
@@ -17,21 +17,19 @@ module EnumeratedAttr
|
|
17
17
|
|
18
18
|
module Glue
|
19
19
|
def enumerated_attr(attribute, enumeration, options = {})
|
20
|
+
# def human_status_value(value = nil)
|
20
21
|
define_method "human_#{attribute}_value" do |value = nil|
|
21
22
|
Base.human(self.class, attribute, value || self.send(attribute))
|
22
23
|
end
|
23
24
|
|
25
|
+
# def status_enumeration
|
24
26
|
define_method "#{attribute}_enumeration" do
|
25
27
|
Base.enumeration(self.class, attribute, enumeration)
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
protected
|
32
|
-
|
33
|
-
def add_validations(attribute, enumeration)
|
34
|
-
validates(attribute, :presence => true, :inclusion => enumeration)
|
30
|
+
if options[:validates]
|
31
|
+
validates attribute, :presence => true, :inclusion => enumeration
|
32
|
+
end
|
35
33
|
end
|
36
34
|
end
|
37
35
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: enumerated_attr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07
|
12
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -81,7 +81,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
81
|
version: '0'
|
82
82
|
segments:
|
83
83
|
- 0
|
84
|
-
hash: -
|
84
|
+
hash: -4522294971138115199
|
85
85
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
segments:
|
92
92
|
- 0
|
93
|
-
hash: -
|
93
|
+
hash: -4522294971138115199
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
96
|
rubygems_version: 1.8.24
|