property_sets 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 84580dd50e10da2429b74e4331d85056f1a43590
4
- data.tar.gz: 9c6d2130e0394cc0d30783e5bc4afc59edf36941
3
+ metadata.gz: 5e986c7d8f9f508a6daae4a6f30ad3dfaf38681a
4
+ data.tar.gz: 195fc1d404d5452d2c700de0f85b9fe06c85ecbe
5
5
  SHA512:
6
- metadata.gz: 1217f63e6258b34921dedf3e9db4f44ab5fe61847fa6f26e605a9334b15e1be53747a0e4ea37fbb150a4879b0bb82e8776f96834606e0a628c9519d4f3703a52
7
- data.tar.gz: dedb51b2e0125909e4933db9521f39de6460530f7401d4549147031bb1073e37c5055c115da66c6188989bb1313cbc894acaf78c446689a225f8f3e0e0a4d450
6
+ metadata.gz: 296140f04fc9f3a941f93f16f01363fc86ed91e23d32ce6c65893d3490c7b03a50debcfc89efa8d3a92c45c6d9d04857eefae41b34e716f29b78ebe425dcca9f
7
+ data.tar.gz: 6db48094d812a3c6e8c156d5edb487d94555935f0faef5999b944ea7b976252fcf8fac3dafdcaa6d5cadb1de357c230e53a0f5aa6850ee9abf5a989161960cbc
@@ -2,8 +2,19 @@ require 'active_support'
2
2
 
3
3
  module PropertySets
4
4
  module PropertySetModel
5
- module InstanceMethods
5
+ # https://dev.mysql.com/doc/refman/5.6/en/storage-requirements.html
6
+ COLUMN_TYPE_LIMITS = {
7
+ 'tinyblob' => 255, # 2^8 - 1
8
+ 'tinytext' => 255,
9
+ 'blob' => 65535, # 2^16 - 1
10
+ 'text' => 65535,
11
+ 'mediumblob' => 16777215, # 2^24 - 1
12
+ 'mediumtext' => 16777215,
13
+ 'longblob' => 4294967295, # 2^32 - 1
14
+ 'longtext' => 4294967295,
15
+ }.freeze
6
16
 
17
+ module InstanceMethods
7
18
  def false?
8
19
  [ "false", "0", "", "off", "n" ].member?(value.to_s.downcase)
9
20
  end
@@ -66,7 +77,7 @@ module PropertySets
66
77
  end
67
78
 
68
79
  def validate_length_of_serialized_data
69
- if value_serialized && self.read_attribute(:value).to_s.size > self.class.columns_hash["value"].limit
80
+ if value_serialized && read_attribute(:value).to_s.size > value_column_limit
70
81
  errors.add(:value, :invalid)
71
82
  end
72
83
  end
@@ -80,6 +91,13 @@ module PropertySets
80
91
  def owner_class_instance
81
92
  send(self.class.owner_class_sym)
82
93
  end
94
+
95
+ def value_column_limit
96
+ column = self.class.columns_hash.fetch('value')
97
+
98
+ # use sql_type because type returns :text for all text types regardless of length
99
+ column.limit || COLUMN_TYPE_LIMITS.fetch(column.sql_type)
100
+ end
83
101
  end
84
102
 
85
103
  module ClassMethods
@@ -1,3 +1,3 @@
1
1
  module PropertySets
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: property_sets
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Primdahl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -73,7 +73,7 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  - !ruby/object:Gem::Dependency
76
- name: mocha
76
+ name: actionpack
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - ">="
@@ -87,7 +87,7 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  - !ruby/object:Gem::Dependency
90
- name: actionpack
90
+ name: rspec
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - ">="
@@ -101,21 +101,21 @@ dependencies:
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  - !ruby/object:Gem::Dependency
104
- name: minitest
104
+ name: wwtd
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: '0'
109
+ version: 0.5.3
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: '0'
116
+ version: 0.5.3
117
117
  - !ruby/object:Gem::Dependency
118
- name: minitest-rg
118
+ name: byebug
119
119
  requirement: !ruby/object:Gem::Requirement
120
120
  requirements:
121
121
  - - ">="
@@ -128,20 +128,6 @@ dependencies:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
130
  version: '0'
131
- - !ruby/object:Gem::Dependency
132
- name: wwtd
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - ">="
136
- - !ruby/object:Gem::Version
137
- version: 0.5.3
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: 0.5.3
145
131
  description: This gem is an ActiveRecord extension which provides a convenient interface
146
132
  for managing per row properties.
147
133
  email: primdahl@me.com
@@ -176,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
162
  version: '0'
177
163
  requirements: []
178
164
  rubyforge_project:
179
- rubygems_version: 2.4.5.1
165
+ rubygems_version: 2.5.1
180
166
  signing_key:
181
167
  specification_version: 4
182
168
  summary: Property sets for ActiveRecord.