inferred_crumpets 0.1.1 → 0.1.2

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: 3149bba0f22205075ec83301699107aa96f02fce
4
- data.tar.gz: 59e4115188b6ec7649395b1ce75b96b9c27a9642
3
+ metadata.gz: c254e2775250e0edbe1538b9755690418d5d9981
4
+ data.tar.gz: 960e259aa006dcdd54b8e2320f11ef7a66f9c049
5
5
  SHA512:
6
- metadata.gz: 2198738d86c4e939da81666cc3174deed5eb2b1d034ba0048efa533cbdff875c16ef7a7e9853118c278baeb0caabc7f04b3194b0a76c8678a3495eec76c0f92c
7
- data.tar.gz: 860372bfe45ceae1b11718f406e4d61000f25f75552a1d07cf77e119403ff87de207003de0bacc825ab0f0712d178acf163b08b7b78216dd3712c9ee1696b63a
6
+ metadata.gz: 0f543722bafb28f88c22ce2420bf3867c6ce3669de38f31085359d002e736f2ce9b4f5caa0b389b5aab3ffd1e5c3121cb147d30d94e35ded67d1dbce63abcf94
7
+ data.tar.gz: ef13a3f10da1567e1950a584c8eb7363479f6d1dfe0ee13644067534069c9d34d91ae6dc9ea6a7d9621fc344b03b772bea87d2d35d834070010cf0d70aa46334
@@ -5,7 +5,7 @@ module InferredCrumpets
5
5
  def self.build_inferred_crumbs!(view_context)
6
6
  subject = view_context.current_object rescue view_context.collection rescue nil
7
7
  return unless subject
8
- parents = [view_context.parent_object].compact
8
+ parents = [view_context.parent_object].compact rescue []
9
9
  build_all!(view_context, subject, parents)
10
10
  end
11
11
 
@@ -42,21 +42,24 @@ module InferredCrumpets
42
42
  end
43
43
 
44
44
  def build_crumb_for_collection!
45
- if action == 'index'
45
+ if subject.is_a?(ActiveRecord::Relation)
46
46
  view_context.crumbs.add_crumb subject_name.pluralize.titleize
47
- else
47
+ elsif subject.is_a?(ActiveRecord::Base)
48
48
  view_context.crumbs.add_crumb subject.class.table_name.titleize, url_for_collection
49
49
  end
50
50
  end
51
51
 
52
52
  def build_crumb_for_action!
53
+ return unless subject.is_a?(ActiveRecord::Base)
54
+
53
55
  if %w(new create).include?(action)
54
- view_context.crumbs.add_crumb 'New', wrapper_options: { class: 'active' }
55
- elsif %w(edit update).include?(action)
56
- build_crumb_for_subject!
57
- view_context.crumbs.add_crumb 'Edit', wrapper_options: { class: 'active' }
58
- elsif action != 'index'
59
- build_crumb_for_subject!
56
+ view_context.crumbs.add_crumb('New', wrapper_options: { class: 'active' })
57
+ return
58
+ end
59
+
60
+ build_crumb_for_subject!
61
+ if %w(edit update).include?(action)
62
+ view_context.crumbs.add_crumb('Edit', wrapper_options: { class: 'active' })
60
63
  end
61
64
  end
62
65
 
@@ -1,3 +1,3 @@
1
1
  module InferredCrumpets
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inferred_crumpets
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
  - Grant Colegate