phenomenal_rails 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,20 +1,20 @@
1
1
  class PhenomenalRails::Engine < Rails::Engine
2
2
  isolate_namespace PhenomenalRails
3
3
  config.app_middleware.use(PhenomenalRails::Middleware)
4
-
4
+
5
5
  config.before_configuration do
6
6
  Rails.configuration.autoload_paths += PhenomenalRails::Loader.autoload_paths(File.expand_path(PhenomenalRails::PATH,Rails.root))
7
7
  end
8
-
8
+
9
9
  config.to_prepare do
10
10
  PhenomenalRails::Loader.prepare(true)
11
11
  end
12
-
12
+
13
13
  config.after_initialize do
14
14
  ActionController::Base.prepend_view_path(PhenomenalRails::Resolver.instance)
15
15
  end
16
-
16
+
17
17
  ActionDispatch::Callbacks.before do |*args|
18
18
  PhenomenalRails::Loader.prepare
19
19
  end
20
- end
20
+ end
@@ -4,20 +4,21 @@ class PhenomenalRails::Middleware
4
4
  @activation_conditions=Array.new
5
5
  Phenomenal::Feature.middleware=self
6
6
  end
7
-
7
+
8
8
  def add_condition(feature,&block)
9
9
  @activation_conditions.push([feature,block])
10
+ sort_activation_conditions
10
11
  end
11
-
12
+
12
13
  def clear_activition_conditions
13
14
  @activation_conditions.clear
14
15
  end
15
-
16
+
16
17
  def call(env)
17
18
  before_call(env)
18
19
  @app.call(env)
19
20
  end
20
-
21
+
21
22
  def before_call(env)
22
23
  @activation_conditions.each do |feature_block|
23
24
  feature,block = feature_block
@@ -26,4 +27,11 @@ class PhenomenalRails::Middleware
26
27
  end
27
28
  end
28
29
  end
30
+
31
+ private
32
+ def sort_activation_conditions
33
+ @activation_conditions.sort! do |a,b|
34
+ Phenomenal::Manager.instance.conflict_policy(a[0],b[0])
35
+ end
36
+ end
29
37
  end
@@ -1,3 +1,3 @@
1
1
  module PhenomenalRails
2
- VERSION = "1.2.4"
2
+ VERSION = "1.2.5"
3
3
  end
@@ -11,9 +11,10 @@ require "phenomenal_rails/path_set"
11
11
 
12
12
  # Set default feature as persistent
13
13
  phen_default_feature.persistent=true
14
+ phen_change_conflict_policy { |a,b| priority_conflict_policy(a,b) }
14
15
 
15
16
 
16
- module PhenomenalRails
17
+ module PhenomenalRails
17
18
  # Phenomenal application folder
18
19
  PATH = "app_phenomenal"
19
20
  end
@@ -1,4 +1,4 @@
1
- %h1
1
+ %h1
2
2
  HOME
3
3
  =@test_title
4
4
  %p
@@ -28,5 +28,11 @@
28
28
  =render :partial=>"shared/partial4"
29
29
  = ActionController::Base.view_paths.paths
30
30
  %br
31
+ %p
32
+ Activation conditions stack
33
+ %br
34
+ =Phenomenal::Feature.class_variable_get(:@@middleware).instance_variable_get(:@activation_conditions)
31
35
  %br
36
+ %br
37
+
32
38
  =Rails.env
@@ -1,7 +1,7 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
3
  include ApplicationHelper
4
-
4
+
5
5
  def home
6
6
  render "pages/home"
7
7
  end
@@ -1,5 +1,6 @@
1
1
  feature :PersistentFeature do
2
2
  is_persistent
3
+ set_priority 1
3
4
  activation_condition do |env|
4
5
  if Rack::Request.new(env).params["activated"]
5
6
  activate_context :TestContext
@@ -10,3 +11,4 @@ feature :PersistentFeature do
10
11
  end
11
12
  end
12
13
  end
14
+
@@ -1 +1,7 @@
1
- feature :TestFeature
1
+ feature :TestFeature do
2
+ set_priority 2
3
+ activation_condition do
4
+ # empty
5
+ end
6
+ end
7
+