resource_renderer 1.2.0 → 1.2.1

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: d2d01cf0d5e32d365bbf31dc58a3c53bc21a613b
4
- data.tar.gz: 4d83cb1d6b9bdaf677f697974ed2334903562f32
3
+ metadata.gz: ee135cf35ef6d693d18379556682510e667018db
4
+ data.tar.gz: cc6b259dfaed3c54d5992401193af65ce7f69eb7
5
5
  SHA512:
6
- metadata.gz: ee0fd6cc858bb4f9dfab9ed6d53bcdabd7456f5fca8a0cce8f2ea781d27c74aead4fa4fdbd5cc1b09a1ce93e0f9f99c1ae9314162bebdc7097ddded9d7783373
7
- data.tar.gz: 4ea7b6497477f3d7aca6f8507eafc57841b44ddca98c39a89a720f0baeed18d6491cabd0da6279bb55c679e0337cbfb2f946b6d1a3af40ec71248b8e4b769a3c
6
+ metadata.gz: 66d61e627911c564a465192a6842064972f7725a9227935bdbee4a2c401250f95fc680dd9fd5abd11ae4206ce63febeaaac7f30912210f5398b1cf5f2b165103
7
+ data.tar.gz: 87c9edaffd4b2170cb0d7dd8d914dd45d4baf20ac9ac49ba7b1f4d639212f6a54a7083db2b0049f5ef464d97121ccda30f089d5c13789248cdaf99e13d98f3fe
@@ -8,8 +8,11 @@ class StringRenderer < ResourceRenderer::AttributeRenderer::Base
8
8
  class: html_class
9
9
  }
10
10
 
11
+ value = value_for_attribute(attribute_name)
12
+ value = value.to_s unless value.is_a?(String)
13
+
11
14
  helper.capture do
12
- h.content_tag(:div, html_attributes) { value_for_attribute(attribute_name) }
15
+ h.content_tag(:div, html_attributes) { value }
13
16
  end
14
17
  end
15
18
  end
@@ -2,13 +2,16 @@ class ThumbnailRenderer < ResourceRenderer::AttributeRenderer::Base
2
2
  def display(attribute_name, label, options = {}, &block)
3
3
  options.reverse_merge!(style: :thumb, image_tag_options: { class: 'thumbnail' })
4
4
  style = options.delete(:style)
5
+ link_to_url_proc = options.delete(:link_to_url) # .try(:call, resource)
6
+ link_to_url = helper.instance_exec(model, &link_to_url_proc) if link_to_url_proc.respond_to?(:call)
5
7
  image_tag_options = options.delete(:image_tag_options)
6
8
 
7
9
  attachment = value_for_attribute(attribute_name)
8
10
  return unless attachment.respond_to?(:url)
9
11
  source = attachment.url(style)
12
+ link_to_target = link_to_url || attachment.url
10
13
 
11
- helper.link_to(attachment.url, { data: { gallery: 'gallery' } }) do
14
+ helper.link_to(link_to_target, { data: { gallery: 'gallery' } }) do
12
15
  helper.image_tag(source, image_tag_options)
13
16
  end
14
17
  end
@@ -1,3 +1,3 @@
1
1
  module ResourceRenderer
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resource_renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-19 00:00:00.000000000 Z
11
+ date: 2016-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails