traco 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.0.0
3
4
  - 1.9.3
4
- - 1.8.7
@@ -1,5 +1,7 @@
1
1
  module Traco
2
2
  module Translates
3
+ TRACO_INSTANCE_METHODS_MODULE_NAME = "TracoInstanceMethods"
4
+
3
5
  def translates(*attributes)
4
6
  options = attributes.extract_options!
5
7
  set_up_once
@@ -29,10 +31,9 @@ module Traco
29
31
 
30
32
  # Instance methods are defined on an included module, so your class
31
33
  # can just redefine them and call `super`, if you need to.
32
- unless @traco_instance_methods
33
- mod = @traco_instance_methods = Module.new
34
- include mod
35
- Traco.const_set("InstanceMethods#{mod.object_id}", mod)
34
+ # http://thepugautomatic.com/2013/07/dsom/
35
+ unless const_defined?(TRACO_INSTANCE_METHODS_MODULE_NAME, _search_ancestors = false)
36
+ include const_set(TRACO_INSTANCE_METHODS_MODULE_NAME, Module.new)
36
37
  end
37
38
 
38
39
  attributes.each do |attribute|
@@ -44,7 +45,7 @@ module Traco
44
45
  def define_localized_reader(attribute, options)
45
46
  fallback = options[:fallback]
46
47
 
47
- @traco_instance_methods.module_eval do
48
+ traco_instance_methods_module.module_eval do
48
49
  define_method(attribute) do
49
50
  @localized_readers ||= {}
50
51
  @localized_readers[attribute] ||= Traco::LocalizedReader.new(self, attribute, :fallback => fallback)
@@ -54,12 +55,16 @@ module Traco
54
55
  end
55
56
 
56
57
  def define_localized_writer(attribute)
57
- @traco_instance_methods.module_eval do
58
+ traco_instance_methods_module.module_eval do
58
59
  define_method("#{attribute}=") do |value|
59
60
  send("#{attribute}_#{I18n.locale}=", value)
60
61
  end
61
62
  end
62
63
  end
64
+
65
+ def traco_instance_methods_module
66
+ const_get(TRACO_INSTANCE_METHODS_MODULE_NAME)
67
+ end
63
68
  end
64
69
  end
65
70
 
data/lib/traco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Traco
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traco
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
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: 2013-07-31 00:00:00.000000000 Z
12
+ date: 2013-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -143,18 +143,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  - - ! '>='
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
- segments:
147
- - 0
148
- hash: 4188964565582496915
149
146
  required_rubygems_version: !ruby/object:Gem::Requirement
150
147
  none: false
151
148
  requirements:
152
149
  - - ! '>='
153
150
  - !ruby/object:Gem::Version
154
151
  version: '0'
155
- segments:
156
- - 0
157
- hash: 4188964565582496915
158
152
  requirements: []
159
153
  rubyforge_project:
160
154
  rubygems_version: 1.8.24