has_metadata_column 1.1.2 → 1.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- N2ViMjZjNzgxZTMwOTQyN2QyMTc5ZTczZmU3YjNhY2JmZTE0MDc4YQ==
5
- data.tar.gz: !binary |-
6
- NjNkZDUwMWFhOTEwNjBmNzhjOGFkZDUzYWFmYzdlZDQyOGE5ODRmOQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NzAxOGE1NTg1Y2JhZTY4NDRmNTdkZWY4ZjM4NmM2MWM0OTdjOWZmY2RhZTE5
10
- NTA5ZjAwMTQwNjZkYWY1NmI5NmM0Nzc1M2FhNzY5N2NmM2ZlOTI1MDQxM2Y3
11
- OGU5NTc0NWEwYWE0NmZjMWI3N2E5YjQyNGE3ZDY2YjUyNmNmMTQ=
12
- data.tar.gz: !binary |-
13
- OWU0NDVmN2EwMDJkNzZhNWEwMzIzMDQ3ODIyN2Y2MWRiYzgzNzI0MTczZDNj
14
- MmVjMWI3NzE3NDQ0M2RkNTZjY2VkNzdmOGEwMmUzYzFkMTA2OGJhYjVlMzVj
15
- OGM3NGU3MzliZTY5OGU1ZTY4OGI1YjEwZTAwNWQ5ZTQzYWZkMTY=
2
+ SHA1:
3
+ metadata.gz: 52691438cbdfe5e44aff286846839bbc18000225
4
+ data.tar.gz: fe23cf4d02b1b51721819f2e8b7789ce79921618
5
+ SHA512:
6
+ metadata.gz: 1c407485b782d83f051c169c6f54590ca26a37374a845519d2f51e838887c05ea267a12981503548938ea6b253948f98384bf11e114ac95a6bed08f950d91598
7
+ data.tar.gz: b4eb239b22eccef3f4a2638a3d7a222ae0a7916a8d6dfbb3b3c5bfafc8590055010331fdd901d518ba82cf4b969a11c1fc9a17ceac9040e6872d6bc7293c111b
@@ -2,14 +2,15 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: has_metadata_column 1.1.3 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "has_metadata_column"
8
- s.version = "1.1.2"
9
+ s.version = "1.1.3"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
12
  s.authors = ["Tim Morgan"]
12
- s.date = "2013-09-04"
13
+ s.date = "2013-12-21"
13
14
  s.description = "Reduce your table width and migration overhead by moving non-indexed columns to a separate metadata column."
14
15
  s.email = "git@timothymorgan.info"
15
16
  s.extra_rdoc_files = [
@@ -25,7 +26,7 @@ Gem::Specification.new do |s|
25
26
  s.licenses = ["MIT"]
26
27
  s.require_paths = ["lib"]
27
28
  s.required_ruby_version = Gem::Requirement.new(">= 1.9")
28
- s.rubygems_version = "2.0.6"
29
+ s.rubygems_version = "2.1.11"
29
30
  s.summary = "Schemaless metadata using JSON columns"
30
31
 
31
32
  if s.respond_to? :specification_version then
@@ -139,16 +139,32 @@ module HasMetadataColumn
139
139
  class << self
140
140
  def define_attribute_methods
141
141
  super
142
- metadata_column_fields.keys.each { |field| define_attribute_method field }
142
+ metadata_column_fields.keys.each { |field| define_attribute_method field.to_s }
143
143
  end
144
144
 
145
145
  def define_method_attribute(attr_name)
146
- return super(attr_name) unless metadata_column_fields.include?(attr_name.to_sym)
147
- attribute_method_matchers.each do |matcher|
148
- method_name = matcher.method_name(attr_name)
149
- define_proxy_call true, generated_attribute_methods, method_name, matcher.method_missing_target, attr_name.to_s
150
- attribute_method_matchers_cache.clear
151
- end
146
+ return super unless metadata_column_fields.include?(attr_name.to_sym)
147
+ generated_attribute_methods.module_eval <<-RUBY, __FILE__, __LINE__ + 1
148
+ def __temp__#{attr_name}
149
+ options = self.class.metadata_column_fields[:#{attr_name}] || {}
150
+ default = options.include?(:default) ? options[:default] : nil
151
+ _metadata_hash.include?('#{attr_name}') ? HasMetadataColumn.metadata_typecast(_metadata_hash['#{attr_name}'], options[:type]) : default
152
+ end
153
+ RUBY
154
+ end
155
+
156
+ def define_method_attribute=(attr_name)
157
+ return super unless metadata_column_fields.include?(attr_name.to_sym)
158
+ generated_attribute_methods.module_eval <<-RUBY, __FILE__, __LINE__ + 1
159
+ def __temp__#{attr_name}=(value)
160
+ attribute_will_change! :#{attr_name}
161
+ old = _metadata_hash['#{attr_name}']
162
+ send (self.class.metadata_column + '='), _metadata_hash.merge('#{attr_name}' => value).to_json
163
+ @_metadata_hash = nil
164
+ @_changed_metadata[attr] = old
165
+ value
166
+ end
167
+ RUBY
152
168
  end
153
169
  end
154
170
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_metadata_column
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-04 00:00:00.000000000 Z
11
+ date: 2013-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '4.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '4.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: boolean
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: sqlite3
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yard
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: redcarpet
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: jeweler
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - '>='
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  description: Reduce your table width and migration overhead by moving non-indexed
@@ -131,17 +131,17 @@ require_paths:
131
131
  - lib
132
132
  required_ruby_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ! '>='
134
+ - - '>='
135
135
  - !ruby/object:Gem::Version
136
136
  version: '1.9'
137
137
  required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  requirements:
139
- - - ! '>='
139
+ - - '>='
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.0.6
144
+ rubygems_version: 2.1.11
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Schemaless metadata using JSON columns