stackable_flash 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,8 @@
1
1
  module StackableFlash
2
2
  class FlashStack < Array
3
3
 
4
+ # TODO: Add smart filters for flashes, like 'sticky' via method_missing.
5
+
4
6
  # Handle the following use case:
5
7
  # flash[:notice] = 'First Part'
6
8
  # flash[:notice] += ' Second Part'
@@ -0,0 +1,23 @@
1
+ module StackableFlash
2
+ class Railtie < Rails::Railtie
3
+
4
+ # Only support Rails 3+?
5
+ #ActiveSupport.on_load(:action_controller) do
6
+ # ActiveSupport.on_load(:after_initialize) do
7
+ # ActionDispatch::Flash::FlashHash.send :include, StackableFlash::StackLayer
8
+ # end
9
+ #end
10
+ config.after_initialize do
11
+ require 'action_pack/version'
12
+ base = if ActionPack::VERSION::MAJOR >= 3
13
+ require 'action_dispatch'
14
+ ActionDispatch::Flash::FlashHash
15
+ else
16
+ require 'action_controller'
17
+ ActionController::Flash::FlashHash
18
+ end
19
+ base.send :include, StackableFlash::StackLayer
20
+ end
21
+
22
+ end
23
+ end
@@ -3,7 +3,9 @@ require "stackable_flash/flash_stack"
3
3
  module StackableFlash
4
4
  module StackLayer
5
5
  def self.included(base)
6
- base.send(:alias_method_chain, "[]=", "stacking")
6
+ base.class_eval do
7
+ alias_method_chain :[]=, :stacking
8
+ end
7
9
  end
8
10
 
9
11
  define_method "[]_with_stacking=" do |key, value|
@@ -1,3 +1,3 @@
1
1
  module StackableFlash
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,9 +1,14 @@
1
+ # Only support Rails 3+?
2
+ #require 'action_dispatch'
1
3
  require "stackable_flash/version"
2
4
  require "stackable_flash/config"
3
5
  require "stackable_flash/flash_stack"
4
6
  require "stackable_flash/stack_layer"
5
7
 
6
8
  module StackableFlash
9
+
10
+ require 'stackable_flash/railtie' if defined?(Rails)
11
+
7
12
  class << self
8
13
  attr_accessor :stacking
9
14
  end
@@ -50,15 +55,3 @@ module StackableFlash
50
55
  end
51
56
 
52
57
  end
53
-
54
- require 'action_pack/version'
55
- base = begin
56
- if ActionPack::VERSION::MAJOR >= 3
57
- require 'action_dispatch'
58
- ActionDispatch::Flash::FlashHash
59
- else
60
- require 'action_controller'
61
- ActionController::Flash::FlashHash
62
- end
63
- end
64
- base.send :include, StackableFlash::StackLayer
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Configure Rails Envinronment
1
+ # Configure Rails Environment
2
2
  ENV["RAILS_ENV"] = "test"
3
3
  require File.expand_path("../dummy/config/environment", __FILE__)
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackable_flash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-18 00:00:00.000000000 Z
12
+ date: 2012-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -125,6 +125,7 @@ files:
125
125
  - lib/stackable_flash.rb
126
126
  - lib/stackable_flash/config.rb
127
127
  - lib/stackable_flash/flash_stack.rb
128
+ - lib/stackable_flash/railtie.rb
128
129
  - lib/stackable_flash/stack_layer.rb
129
130
  - lib/stackable_flash/version.rb
130
131
  - spec/controllers/dummy_controller_spec.rb