before_renders 0.1.0 → 0.2.0
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 +4 -4
- data/README.md +25 -22
- data/before_renders.gemspec +2 -2
- data/lib/action_controller/before_render.rb +24 -0
- data/lib/before_renders/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4685ea9652a6af8231b0e8b173c4bb7efa65adf7
|
|
4
|
+
data.tar.gz: edbfc4eac017d296f25a24d05b11b44d0dda20ae
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1ea95d69fcde63e4e7e472c58e7d2b40680e7376f6a82526db3d6913f6c33958b010557637f2cffdf8a88ffccd6fc54277e0ae7b11de8183735e89517bdf873c
|
|
7
|
+
data.tar.gz: c8be1e5acef086bafbb03ed91d45ffc5ad581222ab1f9f5417a3d583c530268189797786a38dafa1be9b38168f634ec85fb4f77d7869322dcf4868f75df1d1e6
|
data/README.md
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# before_renders [](https://badge.fury.io/rb/before_renders)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
If Rails before_filter or after_filter doesn't enough, try before_renders. Tested in Rails 5.0.6
|
|
4
4
|
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
|
6
5
|
|
|
7
6
|
## Installation
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
In your Gemfile:
|
|
10
9
|
|
|
11
10
|
```ruby
|
|
12
11
|
gem 'before_renders'
|
|
13
12
|
```
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
or system wide:
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
```console
|
|
17
|
+
$ gem install before_renders
|
|
18
|
+
```
|
|
20
19
|
|
|
21
|
-
$ gem install before_renders
|
|
22
20
|
|
|
23
21
|
## Usage
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
## Development
|
|
28
|
-
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
30
|
-
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
32
|
-
|
|
33
|
-
## Contributing
|
|
34
|
-
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/before_renders. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
23
|
+
Now you can execute methods before your rails application start to render anything. Example in application controller like below :
|
|
36
24
|
|
|
25
|
+
```ruby
|
|
26
|
+
class ApplicationController < ActionController::Base
|
|
27
|
+
before_render :set_layout
|
|
37
28
|
|
|
38
|
-
|
|
29
|
+
def set_layout
|
|
30
|
+
# ...
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
```
|
|
39
34
|
|
|
40
|
-
|
|
35
|
+
You can also use in concerns like so:
|
|
36
|
+
```ruby
|
|
37
|
+
module PrintableController
|
|
38
|
+
extend ActiveSupport::Concern
|
|
41
39
|
|
|
40
|
+
included do
|
|
41
|
+
before_render :update_gst_sum, only: [:new, :show, :print_rf]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
```
|
data/before_renders.gemspec
CHANGED
|
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.authors = ["Yakob Ubaidi"]
|
|
10
10
|
spec.email = ["yakob.ubaidi@gmail.com"]
|
|
11
11
|
|
|
12
|
-
spec.summary = %q{if Rails
|
|
13
|
-
spec.description = %q{to allow method execution before starts
|
|
12
|
+
spec.summary = %q{if Rails before_action or after_action isn't enough use before_render.}
|
|
13
|
+
spec.description = %q{to allow method execution before rendering starts}
|
|
14
14
|
spec.homepage = "https://github.com/abigoroth/before_renders"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module ActionController
|
|
2
|
+
module BeforeRender
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do
|
|
6
|
+
define_callbacks :render
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def render(*args)
|
|
10
|
+
run_callbacks :render do
|
|
11
|
+
super
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class_methods do
|
|
16
|
+
def before_render(*names, &block)
|
|
17
|
+
_insert_callbacks(names, block) do |name, options|
|
|
18
|
+
# Rails.logger.debug "name #{name}"
|
|
19
|
+
set_callback :render, :before, name, options
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: before_renders
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yakob Ubaidi
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-01-
|
|
11
|
+
date: 2018-01-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -38,7 +38,7 @@ dependencies:
|
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '10.0'
|
|
41
|
-
description: to allow method execution before starts
|
|
41
|
+
description: to allow method execution before rendering starts
|
|
42
42
|
email:
|
|
43
43
|
- yakob.ubaidi@gmail.com
|
|
44
44
|
executables: []
|
|
@@ -54,6 +54,7 @@ files:
|
|
|
54
54
|
- before_renders.gemspec
|
|
55
55
|
- bin/console
|
|
56
56
|
- bin/setup
|
|
57
|
+
- lib/action_controller/before_render.rb
|
|
57
58
|
- lib/before_renders.rb
|
|
58
59
|
- lib/before_renders/version.rb
|
|
59
60
|
homepage: https://github.com/abigoroth/before_renders
|
|
@@ -79,5 +80,5 @@ rubyforge_project:
|
|
|
79
80
|
rubygems_version: 2.6.10
|
|
80
81
|
signing_key:
|
|
81
82
|
specification_version: 4
|
|
82
|
-
summary: if Rails
|
|
83
|
+
summary: if Rails before_action or after_action isn't enough use before_render.
|
|
83
84
|
test_files: []
|