actionview-helpers-auto_tag_helper 0.1.2 → 0.1.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: c0c1dcdc90bb952b3a479ef054cc4d5002f4e595
4
- data.tar.gz: 0a297d15e416041e960dcbc47b678f95cceb76c7
3
+ metadata.gz: 1ea5ed3f6bda855fc5c91368fb0cb0eeb1c2f67b
4
+ data.tar.gz: 401f7b396a52a341582dd9f1d0da0127acf463cb
5
5
  SHA512:
6
- metadata.gz: a843d1b86c5ebf50d2bc0e5f476a97e2ed2250810218aaa917e6d5a8bd9e9ce211874e2a623b2cbcfc0e930739c96f84d73354335d5d55e35f0a1f4e066a8bbc
7
- data.tar.gz: a1bedb28eb9364511088ff2eba9a8af366bbe065353fe21498940db209afafa1d1c1dd41294934fea4692721e07428326784a206fdeb2a953383c684719d238c
6
+ metadata.gz: 051d6ec33894d2b7cb4485a89a05d524b26fc8bf01e5cb6a012ada7b3e6d3f3f055356cfb53c99d7737a529b01c187ebd1bd0e15f3c6c25860fe0e4c43de6a2f
7
+ data.tar.gz: 4c8df17ed2df77eeaad904aa3ce19cd359ab272cd7894c1bcbab59365f458cf6c49d7c9cad2e06b99c3894bea3e9ea9d60d7ae184470b79ac483b4a7bcb6e212
@@ -17,16 +17,14 @@ module ActionView
17
17
  # html options , ex: {style: "width: 100px; height: 100px; color: #ff0000;" placeholder: 'your name'}
18
18
  #
19
19
  def display_tag(method_name,rec,html_options={})
20
- # if rec.class.respond_to? :reflections
21
- # rec.class.reflections.each do |reflname,refl|
22
- # if refl.association_foreign_key.to_sym == method_name && refl.macro == :belongs_to
23
- # method_name = reflname
24
- # break
25
- # end
26
- # end
27
- # end
20
+ rec.class.try(:reflections).try(:each) do |reflname,refl|
21
+ if refl.foreign_key.to_sym == method_name.to_sym && refl.macro == :belongs_to
22
+ method_name = reflname
23
+ break
24
+ end
25
+ end
28
26
  v = rec.__send__(method_name)
29
- display_tag_with_display_options(v,rec,method_name,html_options) || ( v.respond_to?(:__display__) ? v.__display__ : v.to_s )
27
+ display_tag_with_display_options(v,rec,method_name,html_options) || v.try(:__display__) || v.to_s
30
28
  end
31
29
 
32
30
  def display_tag_with_display_options(v,rec,method_name,html_options={})
@@ -66,7 +64,7 @@ module ActionView
66
64
  def auto_input_tag(sym,model,name,value)
67
65
  column = model.columns_hash[sym.to_s]
68
66
  type = column.type
69
- opts = model.respond_to?(:input_options) ? model.input_options(sym) || {} : {}
67
+ opts = model.try(:input_options,sym) || {}
70
68
  reference_tag(sym,model,name,value) || boolean_tag(type,name,value) || datetime_tag(type,name,value,opts) || number_tag(type,name,value,opts) || text_tag(type,name,value,opts)
71
69
  end
72
70
 
@@ -1,7 +1,7 @@
1
1
  module ActionView
2
2
  module Helpers
3
3
  module AutoTagHelper
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview-helpers-auto_tag_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinjiro Itagaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-06 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler