simple_attribute 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 30aeee5921d4baaf2745a62c810f6970db01dae8
4
- data.tar.gz: 7211e0a0902cbd9ec116a9ffc45a3608ec6965d6
3
+ metadata.gz: 90ea0596dc84e741c57d4bb35f903e1745f7aa8a
4
+ data.tar.gz: 77326d6e6a32d9391e28d54ecc450e54195a7930
5
5
  SHA512:
6
- metadata.gz: d36fe80040f4cc26ba41ec4311a9dd17e5d4f45af6d278972b74450e48d5f5bfee9d5ff13db3458f379e5b0847c9f0fce30d98482cf5bae3959e9d2a2f4da852
7
- data.tar.gz: 32cfdbaea05f094922a7433b1838748d591332df1752417777f22edfc1f81c769839b4e9cedf07c640ec35a7b51b1bf7fc2c113b685ca04abee4c3756abd0cff
6
+ metadata.gz: 452c257bf7d025ff6db056f41a1588f62f6676fd1202ed447ffb95739104ea0eca6055d83e869d61e921ca6c320efd4cba1b33696aeb0b1b9e76d00c10772682
7
+ data.tar.gz: e75146f9286a250748529970088a8f3a0561b156852f3672644ad50e22b3e2a48318fda384f6d3bf802e162643fe2ba80f9bdd3a66118270363945c255fb693d
data/README.md CHANGED
@@ -40,4 +40,4 @@ The gem is available as open source under the terms of the [MIT License](http://
40
40
 
41
41
  ## Code of Conduct
42
42
 
43
- Everyone interacting in the ActiveContent project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hardpixel/simple-attribute/blob/master/CODE_OF_CONDUCT.md).
43
+ Everyone interacting in the SimpleAttribute project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/hardpixel/simple-attribute/blob/master/CODE_OF_CONDUCT.md).
@@ -16,11 +16,20 @@ module SimpleAttribute
16
16
  @options.fetch(:title, :id)
17
17
  end
18
18
 
19
+ # Link url method
20
+ def url_method
21
+ @options.fetch(:url, nil)
22
+ end
23
+
19
24
  # Render attribute
20
25
  def render_attribute
21
26
  label = value.try(label_method)
22
27
  title = value.try(title_method)
23
28
 
29
+ unless url_method.nil?
30
+ value = @context.send(url_method, @value)
31
+ end
32
+
24
33
  link_to label, value, html_options.merge(title: title)
25
34
  end
26
35
  end
@@ -6,6 +6,21 @@ module SimpleAttribute
6
6
  'image'
7
7
  end
8
8
 
9
+ # Render default value
10
+ def render_default_value
11
+ @media_type ||= begin
12
+ media_type = MiniMime.lookup_by_filename("#{default_value}")
13
+ media_type.content_type.to_s.split('/').first
14
+ end
15
+
16
+ if 'image'.in?("#{@media_type}")
17
+ default_url = asset_url(default_value)
18
+ image_tag default_url, html_options
19
+ else
20
+ super
21
+ end
22
+ end
23
+
9
24
  # Render attribute
10
25
  def render_attribute
11
26
  image_tag value, html_options
@@ -1,3 +1,3 @@
1
1
  module SimpleAttribute
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_attribute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonian Guveli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-19 00:00:00.000000000 Z
11
+ date: 2017-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.6.13
147
+ rubygems_version: 2.6.14
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Decorate ActiveRecord model attributes