index_for 0.0.6 → 0.0.7

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: 8c125eb5fdadda564882d4a907036821de8e3c4e
4
- data.tar.gz: cf894b82807b5d94baa736883279abc09e613318
3
+ metadata.gz: 18c31005587f3bedfbab9a622616b09f6a10c7f2
4
+ data.tar.gz: 1a69fafc0bd2ddb8f07c8a122372b4e97c8ad615
5
5
  SHA512:
6
- metadata.gz: 980669b478eb9ce15c3782db85388a4a17560e47df059bc4bb868054ce75a07173465d1a42cdc0abe96c0c68252a1d0bfc5267471858da11adcd4801e4ca4b5e
7
- data.tar.gz: df3b9267ae37b973a75dfe3048dff6b3cf27ffa079afd1c02a50c7a2a4439d3393291f3746b507c0298b4c9426288bfc0d1d28978b8d7768bbd4975ba8f8949c
6
+ metadata.gz: 6abd1286e045ccac6e49a459275aa618d270d2d621619c77234742fd640e6d7cbdae69dd6016f22d59a45b536a88e18f09b3f41c1dc71d70e9406453c734c3ac
7
+ data.tar.gz: b0ca84313a529dc5857de9f7b018dc5c4b3d0f860a3a2409b7cc25a49417d4750086c5854783ab2a047afa2d6cd36bd097a237ce16f1dc6e2f50b0f123121cb0
@@ -25,7 +25,8 @@ module IndexFor
25
25
  end
26
26
 
27
27
  def attribute_label attribute_name
28
- @object.class.human_attribute_name(attribute_name)
28
+ model_class = html_options[:model] || @object.class
29
+ model_class.human_attribute_name(attribute_name)
29
30
  end
30
31
 
31
32
  end
@@ -11,20 +11,21 @@ module IndexFor
11
11
  action_title = translate(:"actions.#{action_name}",
12
12
  default: action_name.to_s.humanize).html_safe
13
13
  action_html_options = apply_html_options :action_link, options[:html] || {}
14
- append_class action_html_options, :"action_#{action_name}"
14
+ append_class action_html_options, :"action_#{action_name}", options[:class]
15
+ action_html_options[:data] ||= {}
16
+ action_html_options[:data].reverse_merge!(options.slice(:method, :confirm))
15
17
 
16
- case action_name
17
- when :show
18
- @template.link_to action_title, @template.polymorphic_path(object),
19
- action_html_options
20
- when :destroy
21
- @template.link_to action_title, @template.polymorphic_path(object),
22
- { data: { method: :delete, confirm: translate(:"actions.confirmation")
23
- }}.merge(action_html_options)
24
- else
25
- @template.link_to action_title, @template.polymorphic_path(object,
26
- action: action_name), action_html_options
27
- end
18
+ link_path = options[:url] || case action_name
19
+ when :show, :destroy
20
+ @template.polymorphic_path(object)
21
+ else
22
+ @template.polymorphic_path(object, action: action_name)
23
+ end
24
+
25
+ action_html_options[:data].reverse_merge!( method: :delete,
26
+ confirm: translate(:"actions.confirmation")) if action_name == :destroy
27
+
28
+ @template.link_to action_title, link_path, action_html_options
28
29
  end
29
30
  end
30
31
 
@@ -1,3 +1,3 @@
1
1
  module IndexFor
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: index_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Theo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-04 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel