awesome_form_attributes 0.0.2 → 0.0.3

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: 77ea3b90f59a11a3da94953d14ec25b36cca3e0f
4
- data.tar.gz: 989217e41491388734106ebe40d0b74066e9f046
3
+ metadata.gz: 3930f76f028727104a329fdfb0b4fe2307d27ee8
4
+ data.tar.gz: c6f537cf775ef060de8cbd4c9e3e3bf536ad93aa
5
5
  SHA512:
6
- metadata.gz: 20a544c2a6633f6cd81945b9c4f2a9ea4027e4874b019a05a55c92aa7042d403513e0a350f3a3fcf6e35107eca17431a336208f51d739ace32bd7ea93c3fe7c6
7
- data.tar.gz: bac97afd0faf1f2cdeb57949199b4ea93da40119d1053ddf97094f8ee98be66e582a59f6d33387b789838950e2323096b9ceb283de96b83240aec8ecf0061ce9
6
+ metadata.gz: fb1d4eba245c48caf90e7b56d229b742de0d7d0cdc55261ecd0ef5722372ca8cbf33eda5c4459f3aced05d8b4c346b9ddee5d823aa4f3442c26e4abd047f5b4b
7
+ data.tar.gz: 5ea01fa6348d31e49edfe537c0fe10dc453e301bedc63a0e3898ad025b9b2a93a048893fce6bc1e5588614a3453232cb3f2ee28c2b0b40d1f2f4b67bffeeb027
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'awesome_form_attributes'
5
- s.version = '0.0.2'
5
+ s.version = '0.0.3'
6
6
  s.authors = ['Zhimeng Sun']
7
7
  s.email = ['zhimengSun@gmail.com']
8
8
  s.homepage = 'https://github.com/zhimengSun/awesome_form_attributes'
@@ -4,11 +4,18 @@ module ActionView
4
4
  [["是", 1], ["否", 0]]
5
5
  end
6
6
 
7
- def localize_attr(sym, opts = {})
8
- klass = controller_name.classify.constantize
7
+ def klass
8
+ controller_name.classify.constantize
9
+ end
10
+
11
+ def has_displayed_names?
12
+ I18n.t(klass.displayed_columns_local_path).is_a?Hash
13
+ end
14
+
15
+ def localize_attr(sym)
9
16
  displayed_name = I18n.t("#{klass.displayed_columns_local_path}.#{sym.to_s}")
10
17
  basic_name = I18n.t("#{klass.default_local_path}.#{sym.to_s}")
11
- return displayed_name || basic_name if opts[:display] == true
18
+ return displayed_name if has_displayed_names? && !(displayed_name =~ /translation missing/)
12
19
  basic_name
13
20
  end
14
21
  end
@@ -3,14 +3,13 @@ module UsedAttrColumns
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  module ClassMethods
6
-
7
- end
8
-
9
- def used_attrs
10
- I18n.t(self.class.default_local_path).try(:keys) || []
11
- end
12
-
13
- def short_used_attrs
14
- base_clos = I18n.t(self.class.displayed_columns_local_path).try(:keys) || used_attrs[0, 5]
6
+ def used_attrs
7
+ I18n.t(self.default_local_path).try(:keys) || []
8
+ end
9
+
10
+ def short_used_attrs
11
+ I18n.t(self.displayed_columns_local_path).try(:keys) || used_attrs[0, 5]
12
+ end
13
+ alias :displayed_columns :short_used_attrs
15
14
  end
16
15
  end
@@ -1,5 +1,5 @@
1
1
  module AwesomeFormAttributes
2
2
  def self.version
3
- "0.0.2"
3
+ "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awesome_form_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zhimeng Sun