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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 20b94e2962763d30e7e52fa8956a233a5a55ee8a
4
- data.tar.gz: e153f1f34232ee4cbba6f02c130cf522b344f091
3
+ metadata.gz: e99f266b24711feae6f13e1af903f465b9cf0d48
4
+ data.tar.gz: a98da069d32903b1824edc5df17f54d5942a4d5a
5
5
  SHA512:
6
- metadata.gz: 15bfc7f4a79bb03b61f2437ed52ff462f11c0ac389830920d9db654c41d072342ce60c9ce048f8cfe75e27d3bc7a35acb696bb524793489d86b15988fd9fcbdb
7
- data.tar.gz: db8f49cd3aff4357d41818e3efacb3a4ad5d2d9be41e73e37f33b4e3cc6f2c131564b978e0c9333c0c190a849bcd28c0b1693855363b7642f6f1983bde2457e6
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.layouts.fetch(action_name) do
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
@@ -1,3 +1,3 @@
1
1
  module LayoutByAction
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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 ApplicationController
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.1
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-26 00:00:00.000000000 Z
11
+ date: 2013-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler