graph_starter 0.6.1 → 0.6.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: 4cbd0a58bce5a5de81839dd259fba3b185c8f69e
4
- data.tar.gz: 0f97453fcac705c6bc47e36951cb6f0065476934
3
+ metadata.gz: b7ac9279e5dab5c536514d8cf61bc16548bdff3a
4
+ data.tar.gz: a2d83d9cb07bc829cf3d801ae0807e12c6896400
5
5
  SHA512:
6
- metadata.gz: 88a4d6c9d636fc194b47868e9fb6adfba8dda5707f8d037082c7359d47d854ad809984dec9732fc7ed892b62dd20002742d65241a1eb70e1a0f62158b57833e8
7
- data.tar.gz: 1fa90a43cb097b8003a41bfc23596c1162d95f233a044b48d1c55ee06a3b015456a26d8d2d73dfe2784d5f01ee53016211f10f72d0e25752fde75bd795b5e04a
6
+ metadata.gz: fd023ba0acc4a0719ac257244cfb52aca43afa7a8088d3996ea27e61e4ab388a9241bc9ead8390e761f02380f279599162fdfd7f6269bcb42a1d36baf53db71b
7
+ data.tar.gz: e8ea82d6f9d71ecfbe2192cf25949319daaa0051d43e7d8df3acd6473c9f83a3f430dcebc8d199b69e000da65494fc98b5e91dbf82bf100d18f704e009d78fc9
@@ -18,7 +18,7 @@ module GraphStarter
18
18
  title: asset.title,
19
19
  url: asset_path(id: asset, model_slug: asset.class.model_slug),
20
20
  description: description,
21
- image: images? && asset.first_image_source_url || nil
21
+ image: asset.first_image_source_url
22
22
  }.reject {|_, v| v.nil? }.tap do |result|
23
23
  model_class.search_properties.each do |property|
24
24
  result[property] = asset.read_attribute(property)
@@ -33,8 +33,9 @@ module GraphStarter
33
33
 
34
34
  def asset_set(var = :asset)
35
35
  associations = []
36
- associations << :images if images?
37
- associations << model_class.category_association if model_class.category_association
36
+ associations << model_class.image_association
37
+ associations << model_class.category_association
38
+ associations.compact
38
39
 
39
40
  scope = model_class_scope(var)
40
41
  scope = yield scope if block_given?
@@ -86,10 +87,6 @@ module GraphStarter
86
87
  model_class_scope.find(params[:id])
87
88
  end
88
89
 
89
- def images?
90
- model_class_scope.has_images?
91
- end
92
-
93
90
  def model_class_scope(var = :asset)
94
91
  #@model_class_scope = if defined?(current_user)
95
92
  # model_class.authorized_for(current_user)
@@ -27,19 +27,39 @@ module GraphStarter
27
27
  def self.has_images
28
28
  @has_images = true
29
29
  has_many :out, :images, type: :HAS_IMAGE, model_class: '::GraphStarter::Image'
30
- has_one :out, :image, type: :HAS_IMAGE, model_class: '::GraphStarter::Image'
31
30
  end
32
31
 
33
32
  def self.has_image
34
- has_images
33
+ @has_image = true
34
+ has_one :out, :image, type: :HAS_IMAGE, model_class: '::GraphStarter::Image'
35
35
  end
36
36
 
37
37
  def self.has_images?
38
38
  !!@has_images
39
39
  end
40
40
 
41
+ def self.has_image?
42
+ !!@has_image
43
+ end
44
+
45
+ def self.image_association
46
+ if has_images?
47
+ :images
48
+ elsif has_image?
49
+ :image
50
+ end
51
+ end
52
+
53
+ def first_image
54
+ if self.class.has_images?
55
+ images.first
56
+ elsif self.class.has_image?
57
+ image
58
+ end
59
+ end
60
+
41
61
  def first_image_source_url
42
- image && image.source_url
62
+ first_image && first_image.source_url
43
63
  end
44
64
 
45
65
  def self.category_association(association_name = nil)
@@ -14,7 +14,7 @@
14
14
  .right.floated.meta
15
15
  i.hide.large.red.icon
16
16
  .header = link_to asset.title, asset_path(asset)
17
- - if asset.class.has_images?
17
+ - if asset.class.has_images? || asset.class.has_image?
18
18
  .image
19
19
  - if asset.first_image_source_url.present?
20
20
  = image_tag asset.first_image_source_url
@@ -1,3 +1,3 @@
1
1
  module GraphStarter
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graph_starter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Underwood