skinny_controllers 0.5.1 → 0.5.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: e268fceb0701364490ca2cef8c5e4f7de86741d7
4
- data.tar.gz: 9ee821888a58aae7e0299dff8b203a76414e9c9d
3
+ metadata.gz: f2e1ec3f77c39858d0b820f251510b79bcc3e4d2
4
+ data.tar.gz: f3248c60ec78d9f32994db937966180d4c423a9b
5
5
  SHA512:
6
- metadata.gz: 39320479afcd9d88d9a5d5ad29823bf1ce6658f5dd8d7110e8c350dc1d7053b3bbf0f841b1373a29242ae0e86287f3a03be7aa1d718fb20d096576982ab7040e
7
- data.tar.gz: dd3e34946f73710f881ceed4470c370b7e2aa8432b2ff27497ffb6556209cde9c826625089028bf12c3cbaf8f186cd44aa0f82b266f27bf680357482f464e2da
6
+ metadata.gz: 06f7c1e5f83f884cf011db58efa12c09043483f7fbb506e67bd02758a711b93e54e5a3f1ea5aaf50fd38b306be080fe5b1e9e41c2e3e95268bba7700b5e6f258
7
+ data.tar.gz: 35b555b099adb1ba915cc88da1c1f62b289de0aacdb6d8a0dea9e923462a992f6efaf0c5b554d9c357187e08b8ef8a0cfc7498ee5e7072b70f9fdf4196940e28
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/NullVoxPopuli/skinny_controllers.svg?branch=master)](https://travis-ci.org/NullVoxPopuli/skinny_controllers)
4
4
  [![Code Climate](https://codeclimate.com/github/NullVoxPopuli/skinny_controllers/badges/gpa.svg)](https://codeclimate.com/github/NullVoxPopuli/skinny_controllers)
5
5
  [![Test Coverage](https://codeclimate.com/github/NullVoxPopuli/skinny_controllers/badges/coverage.svg)](https://codeclimate.com/github/NullVoxPopuli/skinny_controllers/coverage)
6
+ [![Dependency Status](https://gemnasium.com/NullVoxPopuli/skinny_controllers.svg)](https://gemnasium.com/NullVoxPopuli/skinny_controllers)
6
7
 
7
8
  An implementation of role-based policies and operations to help controllers lose weight.
8
9
 
@@ -72,6 +73,28 @@ end
72
73
  ```
73
74
  Note that `each_serializer` and `serializer` is not part of `SkinnyControllers`, and is part of [ActiveModel::Serializers](https://github.com/rails-api/active_model_serializers).
74
75
 
76
+
77
+ ### What if you want to call your own operations?
78
+
79
+ Sometimes, magic is scary. You can call anything you want manually (operations and policies).
80
+
81
+ Here is an example that manually makes the call to the Host Operations and passes the subdomain parameter in to filter the `Host` object on the subdomain.
82
+ ```ruby
83
+ def show
84
+ render json: host_from_subdomain, serializer: each_serializer
85
+ end
86
+
87
+ private
88
+
89
+ def host_from_subdomain
90
+ @host ||= HostOperations::Read.new(current_user, host_params).run
91
+ end
92
+
93
+ def host_params
94
+ params.permit(:subdomain)
95
+ end
96
+ ```
97
+
75
98
  ## Defining Operations
76
99
 
77
100
  Operations should be placed in `app/operations` of your rails app.
@@ -62,7 +62,13 @@ module SkinnyControllers
62
62
  #
63
63
  # @example Operation::Event::Read would become read?
64
64
  def policy_method_name
65
- @policy_method_name ||= Lookup::Policy.method_name_for_operation(self.class.name)
65
+ unless @policy_method_name
66
+ method = Lookup::Policy.method_name_for_operation(self.class.name)
67
+ has_method = policy_class.instance_methods.include?(method.to_sym)
68
+ @policy_method_name = has_method ? method : 'default?'
69
+ end
70
+
71
+ @policy_method_name
66
72
  end
67
73
 
68
74
  # @return a new policy object and caches it
@@ -1,3 +1,3 @@
1
1
  module SkinnyControllers
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skinny_controllers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - L. Preston Sego III
@@ -224,5 +224,5 @@ rubyforge_project:
224
224
  rubygems_version: 2.4.8
225
225
  signing_key:
226
226
  specification_version: 4
227
- summary: SkinnyControllers-0.5.1
227
+ summary: SkinnyControllers-0.5.2
228
228
  test_files: []