happy_path 0.0.1 → 0.0.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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWNjMWExYzJlNGIyODI0NWYwZWU1YTk3ZDQ0MGRlZTMyNDc5ZWUxMA==
4
+ YjViM2I0ZDk0NTFmMjY2YjFiYTZlOGZhM2Q5ODRkM2MxNDI4ZTNlMQ==
5
5
  data.tar.gz: !binary |-
6
- ZjI5ZDNiY2Y4MjFhNDFmZjcxMTAxMDUzZDVmNjZkZDhkZGY2NzViZQ==
6
+ ZGI4MGM5NTI4MTRkMGRhNGZhZWRjYjVmYTRiZjZjNTZlYjhhZWMzYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODc4MDlkOTY3ZDUxZDA5Nzk2ZjFhNDRlM2M0YWVkM2JkMGQ0NGQ2YzYyNDg5
10
- MDFkYTg5NTcyYTUzOTdmODU2NmEyZDE5YmFmOWI0NTQzM2ZkNDIwNWU2NTNk
11
- MWVlNjNiZDE3NTM5NjNjZGY5MmFjOTQ2OWQyM2U3MTE2YmJiMjk=
9
+ ODJhODgzMzc1MGFlYTNhMGRhYmM2ZmQxODYwM2I2YmI0ZjVjYjI0MjhiNWI4
10
+ ZTBhNzE2Y2ZmNzE2NzYwMDU2N2I2ZThhNzQ4Zjk5MTVjNDA3NmNmZTcxMzIy
11
+ ZjA4YmY0MzYyOGY3MWZmYTA5NThmNzg0OTNkODYxMDA4NWMxZTA=
12
12
  data.tar.gz: !binary |-
13
- M2I5MTFkOTNkMGU3MzcwMjE4NzUwYTkxZWMyYjZkZDI4YmMyMzhhZGNjZTRk
14
- MjNjMzE0NWExYjJkODE1YzhkNmJhZGFhOTUwZTc1YTY4MDkxNDMxODAyMmU1
15
- NGQ1YjcxZjgyNGVhYjgzZDIxMTYzYjI1Y2YzZDBhM2I3MGRjNTY=
13
+ MmE1M2I5MzAyNzBlNDRhMGEzMTM3YmViYmMzNDUxYjJmMDE5NzFjMTZmYzg4
14
+ M2FiMmFhNzNlNmE0OTE4OWRhMjYyZjlkZjM3YjAzZGZkNmYwZTJjNTg4ZDk2
15
+ MjcyZjhjODc0NTA2NTM3ZmFkN2RmNGZhZmNmMjI5OTNmM2NjYzc=
@@ -1,3 +1,3 @@
1
1
  module HappyPath
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/happy_path.rb CHANGED
@@ -1,16 +1,15 @@
1
- require "happy_path/version"
2
-
3
1
  module HappyPath
4
2
  extend ActiveSupport::Concern
5
-
3
+ PATHS = ['first', 'last']
4
+
6
5
  def setup_happy_path
7
6
  rescue_from ActiveRecord::RecordNotFound, with: :happy_paths
8
7
  end
9
8
 
10
- module ClassMethods
11
- def happy_paths(exception)
9
+ def follow_happy_paths
10
+ define_method (:happy_paths) do |exception|
12
11
  class_constant = controller_name.classify.constantize
13
- raise exception unless ["first","last"].include?(params[:id]) || class_constant.count.zero?
12
+ raise exception unless self.respond_to?(:show) && HappyPath::PATHS.include?(params[:id]) && !class_constant.count.zero?
14
13
  redirect_to action: :show, id: class_constant.send(params[:id]).id
15
14
  end
16
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: happy_path
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - danReynolds