netzke-core 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
+ v0.3.1
2
+ Fix: persistent_config_manager can now be set to nil, and it will work fine
3
+
1
4
  v0.3.0
5
+ 2009-05-07
2
6
  Refactor: got rid of NetzkeLayout model, now all layouts are stored in netzke_preferences
3
7
  New: persistent_config now has a method for_widget that accepts a block
4
8
  autotest compatibility
data/lib/netzke/base.rb CHANGED
@@ -89,12 +89,29 @@ module Netzke
89
89
 
90
90
  # persistent_config and layout manager classes
91
91
  def persistent_config_manager_class
92
- Netzke::Base.config[:persistent_config_manager].constantize
92
+ Netzke::Base.config[:persistent_config_manager].try(:constantize)
93
93
  rescue NameError
94
94
  nil
95
95
  end
96
96
 
97
-
97
+ # Return persistent config class
98
+ def persistent_config
99
+ # if the class is not present, fake it (it will not store anything, and always return nil)
100
+ if persistent_config_manager_class.nil?
101
+ fake_config = {}
102
+ class << fake_config
103
+ def for_widget(*params, &block)
104
+ yield({})
105
+ end
106
+ def widget_name=(*params)
107
+ end
108
+ end
109
+ fake_config
110
+ else
111
+ persistent_config_manager_class
112
+ end
113
+ end
114
+
98
115
  private
99
116
  def set_default_config(default_config)
100
117
  @@config ||= {}
@@ -167,10 +184,10 @@ module Netzke
167
184
  # persistent_config["window.size"] => 100
168
185
  # This method is user-aware
169
186
  def persistent_config
170
- config_klass = config[:persistent_config] && self.class.persistent_config_manager_class
171
- if config_klass
172
- config_klass.widget_name = id_name # pass to the config class our unique name
173
- config_klass
187
+ if config[:persistent_config]
188
+ config_class = self.class.persistent_config
189
+ config_class.widget_name = id_name # pass to the config class our unique name
190
+ config_class
174
191
  else
175
192
  # if we can't use presistent config, all the calls to it will always return nil, and the "="-operation will be ignored
176
193
  {}
data/netzke-core.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{netzke-core}
5
- s.version = "0.3.0"
5
+ s.version = "0.3.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sergei Kozlov"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netzke-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Kozlov