enumerated_attr 0.0.1 → 0.0.2

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.
@@ -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(:"enumerations.#{klass_name}.#{attribute}.#{value}", :default => value.to_s.humanize)
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
- add_validations(attribute, enumeration) if options[:validates]
29
- end
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
 
@@ -1,3 +1,3 @@
1
1
  module EnumeratedAttr
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: enumerated_attr
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:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-31 00:00:00.000000000 Z
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: -2450379149475425090
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: -2450379149475425090
93
+ hash: -4522294971138115199
94
94
  requirements: []
95
95
  rubyforge_project:
96
96
  rubygems_version: 1.8.24