dry_controller 0.0.2 → 0.0.3

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.
@@ -1,3 +1,3 @@
1
1
  module DryController
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -15,9 +15,7 @@ module DryController
15
15
  end
16
16
  end
17
17
 
18
- protected
19
-
20
- class << self
18
+ module ClassMethods
21
19
 
22
20
  def default_actions(*args)
23
21
  args.each do |meth|
@@ -37,9 +35,13 @@ module DryController
37
35
 
38
36
  def resource_class
39
37
  resource_name.classify.constantize
38
+ rescue NameError => e
39
+ return false
40
40
  end
41
41
 
42
42
  def resource
43
+ return unless resource_class
44
+
43
45
  unless obj = instance_variable_get("@#{resource_name}")
44
46
  obj ||= if params[:id].present?
45
47
  resource_class.where(id: params[:id]).first
@@ -59,6 +61,8 @@ module DryController
59
61
  end
60
62
 
61
63
  def collection
64
+ return unless resource_class
65
+
62
66
  unless objects = instance_variable_get("@#{collection_name}")
63
67
  objects = resource_class.all
64
68
  instance_variable_set("@#{collection_name}", objects)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: