akm-selectable_attr_rails 0.3.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 3
3
- :patch: 3
3
+ :patch: 5
4
4
  :major: 0
@@ -148,6 +148,13 @@ if defined?(I18n)
148
148
  ProductWithI18nDB1.product_type_name_by_key(:dvd).should == 'DVD'
149
149
  ProductWithI18nDB1.product_type_name_by_key(:cd).should == 'CD'
150
150
  ProductWithI18nDB1.product_type_name_by_key(:other).should == 'その他'
151
+
152
+ ProductWithI18nDB1.product_type_hash_array.should == [
153
+ {:id => '01', :key => :book, :name => '書籍', :discount => 0.8},
154
+ {:id => '02', :key => :dvd, :name => 'DVD', :discount => 0.2},
155
+ {:id => '03', :key => :cd, :name => 'CD', :discount => 0.5},
156
+ {:id => '09', :key => :other, :name => 'その他', :discount => 1},
157
+ ]
151
158
 
152
159
  # DBからエントリの名称を動的に変更できます
153
160
  item_book = I18nItemMaster.create(:locale => 'ja', :category_name => 'product_type_cd', :item_no => 1, :item_cd => '01', :name => '本')
@@ -158,6 +165,13 @@ if defined?(I18n)
158
165
  ProductWithI18nDB1.product_type_name_by_key(:other).should == 'その他'
159
166
  ProductWithI18nDB1.product_type_options.should == [['本', '01'], ['DVD', '02'], ['CD', '03'], ['その他', '09']]
160
167
 
168
+ ProductWithI18nDB1.product_type_hash_array.should == [
169
+ {:id => '01', :key => :book, :name => '本', :discount => 0.8},
170
+ {:id => '02', :key => :dvd, :name => 'DVD', :discount => 0.2},
171
+ {:id => '03', :key => :cd, :name => 'CD', :discount => 0.5},
172
+ {:id => '09', :key => :other, :name => 'その他', :discount => 1},
173
+ ]
174
+
161
175
  # DBからエントリの並び順を動的に変更できます
162
176
  item_book.item_no = 4;
163
177
  item_book.save!
@@ -171,6 +185,15 @@ if defined?(I18n)
171
185
  ProductWithI18nDB1.product_type_options.should == [['その他', '09'], ['DVD', '02'], ['CD', '03'], ['本', '01'], ['おもちゃ', '04']]
172
186
  ProductWithI18nDB1.product_type_key_by_id('04').should == :entry_04
173
187
 
188
+ ProductWithI18nDB1.product_type_hash_array.should == [
189
+ {:id => '09', :key => :other, :name => 'その他', :discount => 1},
190
+ {:id => '02', :key => :dvd, :name => 'DVD', :discount => 0.2},
191
+ {:id => '03', :key => :cd, :name => 'CD', :discount => 0.5},
192
+ {:id => '01', :key => :book, :name => '本', :discount => 0.8},
193
+ {:id => '04', :key => :entry_04, :name => 'おもちゃ'}
194
+ ]
195
+
196
+
174
197
  # 英語名を登録
175
198
  item_book = I18nItemMaster.create(:locale => 'en', :category_name => 'product_type_cd', :item_no => 4, :item_cd => '01', :name => 'Book')
176
199
  item_other = I18nItemMaster.create(:locale => 'en', :category_name => 'product_type_cd', :item_no => 1, :item_cd => '09', :name => 'Others')
@@ -181,12 +204,28 @@ if defined?(I18n)
181
204
  # 英語名が登録されていてもI18n.localeが変わらなければ、日本語のまま
182
205
  ProductWithI18nDB1.product_type_options.should == [['その他', '09'], ['DVD', '02'], ['CD', '03'], ['本', '01'], ['おもちゃ', '04']]
183
206
  ProductWithI18nDB1.product_type_key_by_id('04').should == :entry_04
207
+
208
+ ProductWithI18nDB1.product_type_hash_array.should == [
209
+ {:id => '09', :key => :other, :name => 'その他', :discount => 1},
210
+ {:id => '02', :key => :dvd, :name => 'DVD', :discount => 0.2},
211
+ {:id => '03', :key => :cd, :name => 'CD', :discount => 0.5},
212
+ {:id => '01', :key => :book, :name => '本', :discount => 0.8},
213
+ {:id => '04', :key => :entry_04, :name => 'おもちゃ'}
214
+ ]
184
215
 
185
216
  # I18n.localeを変更すると取得できるエントリの名称も変わります
186
217
  I18n.locale = 'en'
187
218
  ProductWithI18nDB1.product_type_options.should == [['Others', '09'], ['DVD', '02'], ['CD', '03'], ['Book', '01'], ['Toy', '04']]
188
219
  ProductWithI18nDB1.product_type_key_by_id('04').should == :entry_04
189
220
 
221
+ ProductWithI18nDB1.product_type_hash_array.should == [
222
+ {:id => '09', :key => :other, :name => 'Others', :discount => 1},
223
+ {:id => '02', :key => :dvd, :name => 'DVD', :discount => 0.2},
224
+ {:id => '03', :key => :cd, :name => 'CD', :discount => 0.5},
225
+ {:id => '01', :key => :book, :name => 'Book', :discount => 0.8},
226
+ {:id => '04', :key => :entry_04, :name => 'Toy'}
227
+ ]
228
+
190
229
  I18n.locale = 'ja'
191
230
  ProductWithI18nDB1.product_type_options.should == [['その他', '09'], ['DVD', '02'], ['CD', '03'], ['本', '01'], ['おもちゃ', '04']]
192
231
  ProductWithI18nDB1.product_type_key_by_id('04').should == :entry_04
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akm-selectable_attr_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi Akima
@@ -9,11 +9,12 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-06 00:00:00 -08:00
12
+ date: 2009-02-23 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
17
+ type: :runtime
17
18
  version_requirement:
18
19
  version_requirements: !ruby/object:Gem::Requirement
19
20
  requirements:
@@ -23,6 +24,7 @@ dependencies:
23
24
  version:
24
25
  - !ruby/object:Gem::Dependency
25
26
  name: activerecord
27
+ type: :runtime
26
28
  version_requirement:
27
29
  version_requirements: !ruby/object:Gem::Requirement
28
30
  requirements:
@@ -32,6 +34,7 @@ dependencies:
32
34
  version:
33
35
  - !ruby/object:Gem::Dependency
34
36
  name: actionpack
37
+ type: :runtime
35
38
  version_requirement:
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
@@ -41,12 +44,13 @@ dependencies:
41
44
  version:
42
45
  - !ruby/object:Gem::Dependency
43
46
  name: akm-selectable_attr
47
+ type: :runtime
44
48
  version_requirement:
45
49
  version_requirements: !ruby/object:Gem::Requirement
46
50
  requirements:
47
51
  - - ">="
48
52
  - !ruby/object:Gem::Version
49
- version: 0.3.1
53
+ version: 0.3.5
50
54
  version:
51
55
  description: selectable_attr_rails makes possible to use selectable_attr in rails application
52
56
  email: akima@gmail.com