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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7da3ed489fbb9b6dcbfd6c99a7f82da6f1f675ef
4
- data.tar.gz: c05fce76c33d1ec0634d515972727895ed6becb9
3
+ metadata.gz: 4685ea9652a6af8231b0e8b173c4bb7efa65adf7
4
+ data.tar.gz: edbfc4eac017d296f25a24d05b11b44d0dda20ae
5
5
  SHA512:
6
- metadata.gz: 927c6eb38fbaef54c90425486d9550d236ff9d0c66eed15305ac018d63a416bad296514d7d4d38aae69f0363d1df972d6a1ffeaa06c05ef8c86855acbfd09f60
7
- data.tar.gz: 5843c1037ce0de9812e7a9581f8ded5135a78815c180b663bdc111e57a2a8d98e4d064f778a35cd910d4129fb4efe15b4e4b4178de6474c59dda75b9e89f7f80
6
+ metadata.gz: 1ea95d69fcde63e4e7e472c58e7d2b40680e7376f6a82526db3d6913f6c33958b010557637f2cffdf8a88ffccd6fc54277e0ae7b11de8183735e89517bdf873c
7
+ data.tar.gz: c8be1e5acef086bafbb03ed91d45ffc5ad581222ab1f9f5417a3d583c530268189797786a38dafa1be9b38168f634ec85fb4f77d7869322dcf4868f75df1d1e6
data/README.md CHANGED
@@ -1,41 +1,44 @@
1
- # BeforeRenders
1
+ # before_renders [![Gem Version](https://badge.fury.io/rb/before_renders.svg)](https://badge.fury.io/rb/before_renders)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/before_renders`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- Add this line to your application's Gemfile:
8
+ In your Gemfile:
10
9
 
11
10
  ```ruby
12
11
  gem 'before_renders'
13
12
  ```
14
13
 
15
- And then execute:
14
+ or system wide:
16
15
 
17
- $ bundle
18
-
19
- Or install it yourself as:
16
+ ```console
17
+ $ gem install before_renders
18
+ ```
20
19
 
21
- $ gem install before_renders
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
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
- ## License
29
+ def set_layout
30
+ # ...
31
+ end
32
+ end
33
+ ```
39
34
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
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
+ ```
@@ -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 before_filter or after_filter isn't enough use before_render.}
13
- spec.description = %q{to allow method execution before starts rendering}
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
@@ -1,3 +1,3 @@
1
1
  module BeforeRenders
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  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.1.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-18 00:00:00.000000000 Z
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 rendering
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 before_filter or after_filter isn't enough use before_render.
83
+ summary: if Rails before_action or after_action isn't enough use before_render.
83
84
  test_files: []