layout_by_action 0.0.1 → 0.0.2
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/lib/layout_by_action/able.rb +11 -3
- data/lib/layout_by_action/version.rb +1 -1
- data/spec/lib/layout_by_action/able_spec.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e99f266b24711feae6f13e1af903f465b9cf0d48
|
4
|
+
data.tar.gz: a98da069d32903b1824edc5df17f54d5942a4d5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dfc9c441cc347fd30b1767590bc1d6c73295780d01b1de3f1a9484b6e2992e79e823b42faa0d7394d5b27a7e48ecdbf1beb507278a95069ca3a8f5f270737d5
|
7
|
+
data.tar.gz: 90ff2be99511dd1adeae9db244c063110c4f61b784a6ea75f65b655f83ce8a7f54a18b6be995fe56caa01a3c66e49b6ce715de86f78fb185bec79a0157669f94
|
@@ -3,9 +3,7 @@ module LayoutByAction
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def layout_by_action(action_name=params[:action])
|
6
|
-
self.class.
|
7
|
-
self.class.default_layout
|
8
|
-
end
|
6
|
+
self.class.layout_heirarchy(action_name).first
|
9
7
|
end
|
10
8
|
|
11
9
|
module ClassMethods
|
@@ -31,6 +29,16 @@ module LayoutByAction
|
|
31
29
|
end
|
32
30
|
layout :layout_by_action
|
33
31
|
end
|
32
|
+
|
33
|
+
def layout_heirarchy(action_name)
|
34
|
+
ancestors.grep(Class).select do |klass|
|
35
|
+
klass.ancestors.grep(Class).include?(ActionController::Base)
|
36
|
+
end.select do |klass|
|
37
|
+
klass != ActionController::Base
|
38
|
+
end.collect do |klass|
|
39
|
+
klass.layouts[action_name] || klass.default_layout
|
40
|
+
end.compact
|
41
|
+
end
|
34
42
|
end
|
35
43
|
|
36
44
|
end
|
@@ -3,11 +3,16 @@ require "spec_helper"
|
|
3
3
|
# stand ins for Rails application controller
|
4
4
|
# it is extended by the railtie
|
5
5
|
|
6
|
-
class
|
6
|
+
class ActionController
|
7
|
+
class Base; end
|
8
|
+
end
|
9
|
+
|
10
|
+
class ApplicationController < ActionController::Base
|
7
11
|
include LayoutByAction::Able
|
8
12
|
def self.layout(method); end
|
9
13
|
end
|
10
14
|
|
15
|
+
|
11
16
|
class YourController < ApplicationController; end
|
12
17
|
|
13
18
|
module LayoutByAction
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: layout_by_action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- barelyknown
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|