petergate 1.3.0 → 1.3.5

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: 8be82833c7259e85ee80f35a935c7762a80bb9d2
4
- data.tar.gz: f45cce812bbdc12d63a317a1759e5fd013c73add
3
+ metadata.gz: 1321402dd89f897c7b4fd9c32b5a6a375e6cccc8
4
+ data.tar.gz: 8b2bfc9840321e2e42ddf04ce2323bf103e3d686
5
5
  SHA512:
6
- metadata.gz: b18da7bf7fc915bc1b67e3f7602c58a6e45cddfc3b1f53753036839f08ca3ec9546ead0ad5166c3c0a02f442df98dabd57f72daa1930a552a196db046871736f
7
- data.tar.gz: ad2529c9ed5c8b84b50874fcd2e0d2d3b8de58d7675239fd1e693d92e463f97516958b63cdaf1f55ad63e552f3b83ad79fca18a3e5567076b041d40f57f1284c
6
+ metadata.gz: d72761ff90b4e08ef1678048aa608c505e17fc9ec365e112f3b64aa5072d35285219a0d4b7e730edeeb9fdff9785027c45a291eba7785a33eb8f284e46cd6ee0
7
+ data.tar.gz: 6ea6888d1818f492d2ab243edc5bfa45ecd88af3aa17cdff88208a99f4b3c565ddda239ba772b90137af8326c65f162b122b21c2bf5e43936b5a328d0c176314
@@ -34,11 +34,12 @@ module Petergate
34
34
  end
35
35
 
36
36
  def controller_message
37
- @_controller_message
37
+ @_controller_message || "Permission Denied"
38
38
  end
39
39
 
40
40
  def inherited(subclass)
41
41
  subclass.instance_variable_set("@_controller_rules", instance_variable_get("@_controller_rules"))
42
+ subclass.instance_variable_set("@_controller_message", instance_variable_get("@_controller_message"))
42
43
  end
43
44
  end
44
45
 
@@ -76,11 +77,11 @@ module Petergate
76
77
  v == :all ? self.class.all_actions : raise("No action for: #{v}")
77
78
  when "Hash"
78
79
  v[:except].present? ? self.class.except_actions(v[:except]) : raise("Invalid values for except: #{v.values}")
79
- when "Array"
80
- v
81
- else
82
- raise("No action for: #{v}")
83
- end
80
+ when "Array"
81
+ v
82
+ else
83
+ raise("No action for: #{v}")
84
+ end
84
85
 
85
86
  h.merge({k => special_values})
86
87
  end
@@ -101,12 +102,16 @@ module Petergate
101
102
  current_user && (roles & current_user.roles).any?
102
103
  end
103
104
 
105
+ def custom_message
106
+ defined?(self.class.controller_message) ? self.class.controller_message : 'Permission Denied'
107
+ end
108
+
104
109
  def forbidden!(msg = nil)
105
110
  respond_to do |format|
106
111
  format.any(:js, :json, :xml) { render nothing: true, status: :forbidden }
107
112
  format.html do
108
113
  destination = current_user.present? ? request.referrer || after_sign_in_path_for(current_user) : root_path
109
- redirect_to destination, notice: (msg || self.class.controller_message || 'Permission Denied')
114
+ redirect_to destination, notice: (msg || custom_message)
110
115
  end
111
116
  end
112
117
  end
@@ -1,3 +1,3 @@
1
1
  module Petergate
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petergate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Isaac Sloan