rails2_view_toggler 0.0.1
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 +7 -0
- data/lib/rails2_view_toggler.rb +39 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 67e4d5375514517f5faa0cfc06404aeac772b6fd
|
|
4
|
+
data.tar.gz: 80f9d53ef31b064de70ee82ea02054f4c0bfb0c1
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ba58b0ff4d89d3bbf3a140dda1c875a8eb7690d25b0bda884e1947b60636050b04af8cd2bd7a35dc9cbdc673eae05093da4493ad5c6ceac71b566d7a990df2b2
|
|
7
|
+
data.tar.gz: 4cdf049160cb8bff23d8b7a6c0252458d64277471873436a67103b903ed8a9dad2414508886b09bc8db84328a749aa5611e6e12bd6ea63ac1e7aae561c7e0a36
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
ActionView::Base
|
|
2
|
+
|
|
3
|
+
module Rails2ViewToggler
|
|
4
|
+
|
|
5
|
+
mattr_accessor :mapping
|
|
6
|
+
|
|
7
|
+
def enable(opts)
|
|
8
|
+
Rails2ViewToggler.mapping ||= {}
|
|
9
|
+
|
|
10
|
+
Rails2ViewToggler.mapping.merge!(opts)
|
|
11
|
+
|
|
12
|
+
::ActionView::Base.module_eval do
|
|
13
|
+
include Rails2ViewToggler::PartialTogglingSupport
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
module_function :enable
|
|
17
|
+
|
|
18
|
+
module PartialTogglingSupport
|
|
19
|
+
|
|
20
|
+
def partial_name_when_toggle_on(original_name)
|
|
21
|
+
paths = original_name.split('/')
|
|
22
|
+
paths[-1] = "new_#{paths[-1]}"
|
|
23
|
+
paths.join('/')
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def render_with_partials_toggling(options = {}, local_assigns = {}, &block)
|
|
27
|
+
if Hash === options && options[:partial] && toggle_is_on = Rails2ViewToggler.mapping[options[:partial]]
|
|
28
|
+
options[:partial] = partial_name_when_toggle_on(options[:partial]) if toggle_is_on
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
render_without_partials_toggling(options, local_assigns, &block)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.included(base)
|
|
35
|
+
base.alias_method_chain :render, :partials_toggling
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rails2_view_toggler
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Bill DePhillips
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-04-28 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Allows simple view toggling
|
|
14
|
+
email: bill.dephillips@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/rails2_view_toggler.rb
|
|
20
|
+
homepage: https://github.com/ThoughtWorksStudios/rails2_view_toggler
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubyforge_project:
|
|
40
|
+
rubygems_version: 2.0.14
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Allows conditional rendering based on toggles
|
|
44
|
+
test_files: []
|