maquina 0.2.2 → 0.2.4

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
  SHA256:
3
- metadata.gz: 040c1d643734bb33ae456b0bd092b87b250d0b4d56f03548d569594f3d6892f3
4
- data.tar.gz: a17889606d8033a9e068cd212d5557f7cc77b60fd8f82d7f6f951974a526866f
3
+ metadata.gz: 364438ad137141326a74edaa58326851f341adc1f8acb322dd8a97cb5978a083
4
+ data.tar.gz: 970677e48f9feb4134fc488a83026a50c73d7db3ce95b840fde885240161aa4b
5
5
  SHA512:
6
- metadata.gz: 4654d0514915f2fe7d7577ad73487a78d5b0036df114c82950a80e8f737a5b9d92bf7b163eeb316c2758428c80e0fe5dc52b13563cfeb9a2666323b62a4c773f
7
- data.tar.gz: fe807c89c747bcf9b7fc95b7590edcd331b0ee6eab5e966ebe5576fb48e580bc445552d3e5d0fd4d773cf8b36054e8b2e9c90c0d9a1c29631c96312d0b0a670e
6
+ metadata.gz: ed1dca346e40c2fe3ae250c83fa614865ba3f3bc8a6a2889aae2b455ac330e779ecc00132996be2b1512b7f1531a91ef0098d2c94b636ba0af9fe3b0bcd86dcf
7
+ data.tar.gz: df0df2c766a02f9395b98c3e9a127e8e7fc8b29ba88df23c3041cde9de50cf8295d1243d012c1c8cea8e7def0c70b6e55ac34d560802d7392cebac88b0989616
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maquina (0.2.2)
4
+ maquina (0.2.4)
5
5
  action_policy (~> 0.6.3)
6
6
  bcrypt (~> 3.1.7)
7
7
  importmap-rails (~> 1.2.0)
@@ -16,6 +16,7 @@ module Maquina
16
16
  end
17
17
 
18
18
  @status = @resource.errors.empty? ? :created : :unprocessable_entity
19
+ Rails.logger.debug "CREATE validation: #{@resource.errors.inspect}" if status == :unprocessable_entity
19
20
  response.status = @status
20
21
  set_flash_message(@status)
21
22
 
@@ -8,10 +8,11 @@ module Maquina
8
8
  def destroy(&block)
9
9
  @resource ||= begin
10
10
  scope = resource_class
11
- # TODO: Implement policy authorization (ActionPolicy)
12
- # scope = scope.where(organization)
13
- # TODO: Implement filtering by organization
11
+ scope = authorized_scope(scope) if policy_class.present?
12
+
14
13
  scope.find_by!(find_by_param => params[:id])
14
+
15
+ authorize! resource, with: policy_class if policy_class.present?
15
16
  end
16
17
 
17
18
  @resource.destroy
@@ -8,8 +8,7 @@ module Maquina
8
8
  def edit(&block)
9
9
  @resource ||= begin
10
10
  scope = resource_class
11
- # TODO: Implement filtering by organization
12
- # scope = scope.where(organization)
11
+ scope = authorized_scope(scope) if policy_class.present?
13
12
  scope = yield(scope) if block.present?
14
13
 
15
14
  resource = scope.find_by!(find_by_param => params[:id])
@@ -14,7 +14,7 @@ module Maquina
14
14
  scope = authorized_scope(scope) if policy_class.present?
15
15
 
16
16
  search_value = params[:q]&.strip
17
- scope = scope.search_full(search_value) if search_value.present?
17
+ scope = scope.search_full(search_value) if search_value.present? && resource_class.searchable?
18
18
 
19
19
  scope = yield(scope) if block.present?
20
20
 
@@ -65,9 +65,9 @@ module Maquina
65
65
  method_name = :secure_params
66
66
  method_action_name = "#{action_name}_#{method_name}".to_sym
67
67
 
68
- if respond_to?(method_action_name)
68
+ if respond_to?(method_action_name, true)
69
69
  send(method_action_name)
70
- elsif respond_to?(method_name)
70
+ elsif respond_to?(method_name, true)
71
71
  send(method_name)
72
72
  else
73
73
  params.require(resource_class.model_name.element.to_sym).permit(form_attributes.flat_map { |field| field.keys })
@@ -8,8 +8,8 @@ module Maquina
8
8
  def update(&block)
9
9
  @resource ||= begin
10
10
  scope = resource_class
11
- # scope = scope.where(organization)
12
- # TODO: Implement filtering by organization
11
+ scope = authorized_scope(scope) if policy_class.present?
12
+
13
13
  resource = scope.find_by!(find_by_param => params[:id])
14
14
 
15
15
  authorize! resource, with: policy_class if policy_class.present?
@@ -20,6 +20,7 @@ module Maquina
20
20
  saved = @resource.update(resource_secure_params)
21
21
 
22
22
  status = saved ? :accepted : :unprocessable_entity
23
+ Rails.logger.debug "UPDATE validation: #{@resource.errors.inspect}" if status == :unprocessable_entity
23
24
  response.status = status
24
25
  set_flash_message(status)
25
26
 
@@ -1,3 +1,3 @@
1
1
  module Maquina
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maquina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Alberto Chávez