netzke-core 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ gemfile:
6
+ - test/core_test_app/gemfiles/rails3_1.gemfile
7
+ - test/core_test_app/gemfiles/rails3_2.gemfile
8
+ before_script:
9
+ - chmod 777 ./config/ci/before-travis.sh
10
+ - ./config/ci/before-travis.sh
11
+ script:
12
+ - export DISPLAY=:99.0
13
+ - cd test/core_test_app
14
+ - bundle exec rake db:create db:migrate RAILS_ENV=test
15
+ - bundle exec rspec spec
16
+ - bundle exec cucumber features
17
+ branches:
18
+ only:
19
+ - master
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,6 @@
1
+ = v0.7.6 - 2012-07-27
2
+ * Rails 3.2
3
+
1
4
  = v0.7.5 - 2012-03-05
2
5
  * API changes
3
6
  * The :class_name option must *always* include the full class name now. So, "Basepack::GridPanel" won't work, instead do "Netzke::Basepack::GridPanel"
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Netzke Core
2
2
 
3
- Netzke Core is the bare bones of the [Netzke framework](https://github.com/skozlov/netzke). For pre-built full-featured components (like grids, forms, tab/accordion panels, applications, etc), see [netzke-basepack](http://github.com/skozlov/netzke-basepack) (Ext JS).
3
+ [![Build Status](https://secure.travis-ci.org/skozlov/netzke-core.png?branch=master)](http://travis-ci.org/skozlov/netzke-core)
4
+
5
+ Netzke Core is the bare bones of the [Netzke framework](https://github.com/nomadcoder/netzke). For pre-built full-featured components (like grids, forms, tab/accordion panels, applications, etc), see [netzke-basepack](http://github.com/nomadcoder/netzke-basepack) (Ext JS).
4
6
 
5
7
  Netzke Core takes the burden of implementing the following key aspects of the framework:
6
8
 
@@ -15,23 +17,29 @@ Netzke Core takes the burden of implementing the following key aspects of the fr
15
17
 
16
18
  All this provides for fast, low-traffic, robust, highly maintainable applications.
17
19
 
20
+ ## Requirements
21
+
22
+ * Ruby >= 1.9.2 (1.8.7 may work, too)
23
+ * Rails ~> 3.1.0
24
+ * Ext JS = 4.0.2a
25
+
18
26
  ## Getting started
19
27
 
20
- * Follow the simple [installation](https://github.com/skozlov/netzke-core/wiki/Installation) steps.
21
- * Learn how to build the [Hello World!](https://github.com/skozlov/netzke-core/wiki/Hello-world-extjs) component.
22
- * Dive into the [documentation](https://github.com/skozlov/netzke/wiki).
28
+ * Follow the simple [installation](https://github.com/nomadcoder/netzke-core/wiki/Installation) steps.
29
+ * Learn how to build the [Hello World!](https://github.com/nomadcoder/netzke-core/wiki/Hello-world-extjs) component.
30
+ * Dive into the [documentation](https://github.com/nomadcoder/netzke/wiki).
23
31
  * Get help on the [Google Groups](http://groups.google.com/group/netzke).
24
32
 
25
33
  ## Testing and playing with Netzke Core
26
34
 
27
- Netzke Core is bundled with Cucumber and RSpec tests. If you would like to contribute to the project, you may want to learn how to [run the tests](https://github.com/skozlov/netzke-core/wiki/Automated-testing).
35
+ Netzke Core is bundled with Cucumber and RSpec tests. If you would like to contribute to the project, you may want to learn how to [run the tests](https://github.com/nomadcoder/netzke-core/wiki/Automated-testing).
28
36
 
29
- Besides, the bundled test application is a convenient [playground](https://github.com/skozlov/netzke-core/wiki/Playground) for those who search to experiment with the framework.
37
+ Besides, the bundled test application is a convenient [playground](https://github.com/nomadcoder/netzke-core/wiki/Playground) for those who search to experiment with the framework.
30
38
 
31
39
  ## Useful links
32
40
  * [Project website](http://netzke.org)
33
- * [Documentation](https://github.com/skozlov/netzke/wiki)
34
- * [Live-demo](http://demo.netzke.org) (features [Netzke Basepack](https://github.com/skozlov/netzke-basepack), with sample code)
41
+ * [Documentation](https://github.com/nomadcoder/netzke/wiki)
42
+ * [Live-demo](http://demo.netzke.org) (features [Netzke Basepack](https://github.com/nomadcoder/netzke-basepack), with sample code)
35
43
  * [Twitter](http://twitter.com/netzke) - latest news about the framework
36
44
  * [Author's twitter](http://twitter.com/nomadcoder) - author's rambling about OS X, productivity, lifestyle, and what not
37
45
 
@@ -43,4 +51,4 @@ With Rails 2 (and Ext 3 only), use versions 0.5.x (*not maintained*)
43
51
 
44
52
  ---
45
53
  Copyright (c) 2008-2011 NomadCoder, released under the MIT license
46
- Note, that Ext JS itself is licensed [differently](http://www.sencha.com/products/extjs/license/)
54
+ Note, that Ext JS itself is licensed [differently](http://www.sencha.com/products/extjs/license/)
data/Rakefile CHANGED
@@ -39,7 +39,11 @@ Rake::TestTask.new(:test) do |test|
39
39
  test.verbose = true
40
40
  end
41
41
 
42
- require 'rake/rdoctask'
42
+ begin
43
+ require 'rdoc/task'
44
+ rescue LoadError
45
+ require 'rake/rdoctask'
46
+ end
43
47
  Rake::RDocTask.new do |rdoc|
44
48
  require './lib/netzke/core/version'
45
49
  version = Netzke::Core::Version::STRING
@@ -56,4 +60,4 @@ namespace :rdoc do
56
60
  task :publish => :rdoc do
57
61
  `scp -r rdoc/* fl:www/api.netzke.org/core`
58
62
  end
59
- end
63
+ end
@@ -0,0 +1,11 @@
1
+ # Start xvfb in preparation for cucumber
2
+ sh -e /etc/init.d/xvfb start
3
+
4
+ # fetch extjs
5
+ wget http://cdn.sencha.io/ext-4.0.7-gpl.zip
6
+ unzip -q -d test/core_test_app/public/ -n ext-4.0.7-gpl.zip
7
+ mv test/core_test_app/public/ext-4.0.7-gpl test/core_test_app/public/extjs
8
+
9
+ # cp db configuration
10
+ cp test/core_test_app/config/database.yml.travis test/core_test_app/config/database.yml
11
+
@@ -36,6 +36,10 @@ module Netzke
36
36
 
37
37
  included do
38
38
  alias_method_chain :js_config, :actions
39
+
40
+ # Returns registered actions
41
+ class_attribute :registered_actions
42
+ self.registered_actions = []
39
43
  end
40
44
 
41
45
  module ClassMethods
@@ -61,14 +65,7 @@ module Netzke
61
65
 
62
66
  # Register an action
63
67
  def register_action(name)
64
- current_actions = read_inheritable_attribute(:actions) || []
65
- current_actions << name
66
- write_inheritable_attribute(:actions, current_actions.uniq)
67
- end
68
-
69
- # Returns registered actions
70
- def registered_actions
71
- read_inheritable_attribute(:actions) || []
68
+ self.registered_actions |= [name]
72
69
  end
73
70
 
74
71
  end
data/lib/netzke/base.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'active_support/core_ext'
2
- require 'active_support/memoizable'
3
2
  require 'netzke/core_ext'
4
3
  require 'netzke/javascript'
5
4
  require 'netzke/stylesheets'
@@ -58,8 +57,6 @@ module Netzke
58
57
  attr_reader :global_id
59
58
 
60
59
  class << self
61
- extend ActiveSupport::Memoizable
62
-
63
60
  # Component's short class name, e.g.:
64
61
  # "Netzke::Module::SomeComponent" => "Module::SomeComponent"
65
62
  def short_component_class_name
@@ -67,7 +64,6 @@ module Netzke
67
64
  end
68
65
 
69
66
  # Component's class, given its name.
70
- # Note: this method will be memoized if Rails.configuration.cache_classes is true.
71
67
  def constantize_class_name(class_name)
72
68
  class_name.constantize # used to be more complex than this, but appeared to be difficult to debug
73
69
  end
@@ -1,5 +1,3 @@
1
- # require 'active_support/core_ext/class/inheritable_attributes'
2
-
3
1
  module Netzke
4
2
  # This module takes care of components composition.
5
3
  #
@@ -25,7 +23,11 @@ module Netzke
25
23
 
26
24
  included do
27
25
 
28
- # Loads a component on browser's request. Every Nettzke component gets this endpoint.
26
+ # Returns registered components
27
+ class_attribute :registered_components
28
+ self.registered_components = []
29
+
30
+ # Loads a component on browser's request. Every Netzke component gets this endpoint.
29
31
  # <tt>params</tt> should contain:
30
32
  # * <tt>:cache</tt> - an array of component classes cached at the browser
31
33
  # * <tt>:id</tt> - reference to the component
@@ -87,60 +89,53 @@ module Netzke
87
89
 
88
90
  # Register a component
89
91
  def register_component(name)
90
- current_components = read_inheritable_attribute(:components) || []
91
- current_components << name
92
- write_inheritable_attribute(:components, current_components.uniq)
93
- end
94
-
95
- # Returns registered components
96
- def registered_components
97
- read_inheritable_attribute(:components) || []
92
+ self.registered_components |= [name]
98
93
  end
99
94
 
100
95
  end
101
96
 
102
- module InstanceMethods
103
- extend ActiveSupport::Memoizable
104
-
105
- def items #:nodoc:
106
- @items_with_normalized_components
107
- end
97
+ def items #:nodoc:
98
+ @items_with_normalized_components
99
+ end
108
100
 
109
- # DEPRECATED in favor of Base.component
110
- def initial_components
111
- {}
112
- end
101
+ # DEPRECATED in favor of Base.component
102
+ def initial_components
103
+ {}
104
+ end
113
105
 
114
- # All components for this instance, which includes components defined on class level, and components detected in :items
115
- def components
116
- @components ||= self.class.registered_components.inject({}){ |res, name| res.merge(name.to_sym => send(COMPONENT_METHOD_NAME % name)) }.merge(config[:components] || {})
117
- end
106
+ # All components for this instance, which includes components defined on class level, and components detected in :items
107
+ def components
108
+ @components ||= self.class.registered_components.inject({}){ |res, name| res.merge(name.to_sym => send(COMPONENT_METHOD_NAME % name)) }.merge(config[:components] || {})
109
+ end
118
110
 
119
- def eager_loaded_components
120
- components.reject{|k,v| v[:lazy_loading]}
121
- end
111
+ def eager_loaded_components
112
+ components.reject{|k,v| v[:lazy_loading]}
113
+ end
122
114
 
123
- # DEPRECATED
124
- def add_component(aggr)
125
- components.merge!(aggr)
126
- end
115
+ # DEPRECATED
116
+ def add_component(aggr)
117
+ components.merge!(aggr)
118
+ end
127
119
 
128
- # DEPRECATED
129
- def remove_component(aggr)
130
- if config[:persistent_config]
131
- persistence_manager_class.delete_all_for_component("#{global_id}__#{aggr}")
132
- end
133
- components[aggr] = nil
120
+ # DEPRECATED
121
+ def remove_component(aggr)
122
+ if config[:persistent_config]
123
+ persistence_manager_class.delete_all_for_component("#{global_id}__#{aggr}")
134
124
  end
125
+ components[aggr] = nil
126
+ end
135
127
 
136
- # Called when the method_missing tries to processes a non-existing component
137
- def component_missing(aggr)
138
- flash :error => "Unknown component #{aggr} for component #{name}"
139
- {:feedback => @flash}.to_nifty_json
140
- end
128
+ # Called when the method_missing tries to processes a non-existing component
129
+ def component_missing(aggr)
130
+ flash :error => "Unknown component #{aggr} for component #{name}"
131
+ {:feedback => @flash}.to_nifty_json
132
+ end
141
133
 
142
- # Recursively instantiates a component based on its "path": e.g. if we have component :component1 which in its turn has component :component2, the path to the latter would be "component1__component2"
143
- def component_instance(name, strong_config = {})
134
+ # Recursively instantiates a component based on its "path": e.g. if we have component :component1 which in its turn has component :component2, the path to the latter would be "component1__component2"
135
+ # TODO: strong_config should probably be thrown away, and is not taken into account when caching the results
136
+ def component_instance(name, strong_config = {})
137
+ @component_instance_cache ||= {}
138
+ @component_instance_cache[name] ||= begin
144
139
  composite = self
145
140
  name.to_s.split('__').each do |cmp|
146
141
  cmp = cmp.to_sym
@@ -160,72 +155,70 @@ module Netzke
160
155
  end
161
156
  composite
162
157
  end
158
+ end
163
159
 
164
- memoize :component_instance # for performance
165
-
166
- # All components that we depend on (used to render all necessary JavaScript and stylesheets)
167
- def dependency_classes
168
- res = []
160
+ # All components that we depend on (used to render all necessary JavaScript and stylesheets)
161
+ def dependency_classes
162
+ res = []
169
163
 
170
- eager_loaded_components.keys.each do |aggr|
171
- res += component_instance(aggr).dependency_classes
172
- end
164
+ eager_loaded_components.keys.each do |aggr|
165
+ res += component_instance(aggr).dependency_classes
166
+ end
173
167
 
174
- res += self.class.class_ancestors
168
+ res += self.class.class_ancestors
175
169
 
176
- res << self.class
177
- res.uniq
178
- end
170
+ res << self.class
171
+ res.uniq
172
+ end
179
173
 
180
- # DEPRECATED
181
- def js_component(*args)
182
- self.class.js_component(*args)
183
- end
174
+ # DEPRECATED
175
+ def js_component(*args)
176
+ self.class.js_component(*args)
177
+ end
184
178
 
185
- # Returns global id of a component in the hierarchy, based on passed reference that follows
186
- # the double-underscore notation. Referring to "parent" is allowed. If going to far up the hierarchy will
187
- # result in <tt>nil</tt>, while referring to a non-existent component will simply provide an erroneous ID.
188
- # Example:
189
- # <tt>parent__parent__child__subchild</tt> will traverse the hierarchy 2 levels up, then going down to "child",
190
- # and further to "subchild". If such a component exists in the hierarchy, its global id will be returned, otherwise
191
- # <tt>nil</tt> will be returned.
192
- def global_id_by_reference(ref)
193
- ref = ref.to_s
194
- return parent && parent.global_id if ref == "parent"
195
- substr = ref.sub(/^parent__/, "")
196
- if substr == ref # there's no "parent__" in the beginning
197
- return global_id + "__" + ref
198
- else
199
- return parent.global_id_by_reference(substr)
200
- end
179
+ # Returns global id of a component in the hierarchy, based on passed reference that follows
180
+ # the double-underscore notation. Referring to "parent" is allowed. If going to far up the hierarchy will
181
+ # result in <tt>nil</tt>, while referring to a non-existent component will simply provide an erroneous ID.
182
+ # Example:
183
+ # <tt>parent__parent__child__subchild</tt> will traverse the hierarchy 2 levels up, then going down to "child",
184
+ # and further to "subchild". If such a component exists in the hierarchy, its global id will be returned, otherwise
185
+ # <tt>nil</tt> will be returned.
186
+ def global_id_by_reference(ref)
187
+ ref = ref.to_s
188
+ return parent && parent.global_id if ref == "parent"
189
+ substr = ref.sub(/^parent__/, "")
190
+ if substr == ref # there's no "parent__" in the beginning
191
+ return global_id + "__" + ref
192
+ else
193
+ return parent.global_id_by_reference(substr)
201
194
  end
195
+ end
202
196
 
203
- protected
204
-
205
- def normalize_components(items) #:nodoc:
206
- @component_index ||= 0
207
- @items_with_normalized_components = items.each_with_index.map do |item, i|
208
- if is_component_config?(item)
209
- component_name = item[:name] || :"netzke_#{@component_index}" # default name/item_id for child components
210
- @component_index += 1
211
- self.class.component(component_name.to_sym, item)
212
- component_name.to_sym.component # replace current item with a reference to component
213
- elsif item.is_a?(Hash)
214
- item[:items].is_a?(Array) ? item.merge(:items => normalize_components(item[:items])) : item
215
- else
216
- item
217
- end
197
+ protected
198
+
199
+ def normalize_components(items) #:nodoc:
200
+ @component_index ||= 0
201
+ @items_with_normalized_components = items.each_with_index.map do |item, i|
202
+ if is_component_config?(item)
203
+ component_name = item[:name] || :"netzke_#{@component_index}" # default name/item_id for child components
204
+ @component_index += 1
205
+ self.class.component(component_name.to_sym, item)
206
+ component_name.to_sym.component # replace current item with a reference to component
207
+ elsif item.is_a?(Hash)
208
+ item[:items].is_a?(Array) ? item.merge(:items => normalize_components(item[:items])) : item
209
+ else
210
+ item
218
211
  end
219
212
  end
213
+ end
220
214
 
221
- def normalize_components_in_items #:nodoc:
222
- normalize_components(config[:items]) if config[:items]
223
- end
215
+ def normalize_components_in_items #:nodoc:
216
+ normalize_components(config[:items]) if config[:items]
217
+ end
224
218
 
225
- def is_component_config?(c) #:nodoc:
226
- !!(c.is_a?(Hash) && c[:class_name])
227
- end
228
- end
219
+ def is_component_config?(c) #:nodoc:
220
+ !!(c.is_a?(Hash) && c[:class_name])
221
+ end
229
222
 
230
223
  end
231
224
  end
@@ -16,26 +16,28 @@ module Netzke
16
16
  module ConfigToDslDelegator
17
17
  extend ActiveSupport::Concern
18
18
 
19
+ included do
20
+ class_attribute :delegated_options
21
+ self.delegated_options = []
22
+ end
23
+
19
24
  module ClassMethods
20
25
  # Delegates specified configuration options to the class level. See ConfigToDslDelegator.
21
26
  def delegates_to_dsl(*option_names)
22
- delegated_options = read_inheritable_attribute(:delegated_options) || []
23
- delegated_options += option_names
24
- write_inheritable_attribute(:delegated_options, delegated_options)
27
+ self.delegated_options |= option_names
25
28
  end
26
29
 
27
30
  def inherited(inherited_class) # :nodoc:
28
31
  super
29
32
 
30
- properties = read_inheritable_attribute(:delegated_options) || []
31
- properties.size.times do |i|
32
- inherited_class.class.send(:define_method, properties[i], lambda { |value|
33
- default_config = read_inheritable_attribute(:default_config) || {}
34
- default_config.merge!(properties[i].to_sym => value)
35
- write_inheritable_attribute(:default_config, default_config)
33
+ properties = self.delegated_options
34
+ properties.each do |property|
35
+ inherited_class.class.send(:define_method, property, lambda { |value|
36
+ default_config = self.default_config_attr.dup
37
+ self.default_config_attr = default_config.merge(property.to_sym => value)
36
38
  })
37
39
  end
38
40
  end
39
41
  end
40
42
  end
41
- end
43
+ end
@@ -10,6 +10,10 @@ module Netzke
10
10
  CONFIGURATION_LEVELS.each do |level|
11
11
  define_method("weak_#{level}_options"){ {} }
12
12
  end
13
+
14
+ class_attribute :default_config_attr
15
+ self.default_config_attr = {}
16
+
13
17
  end
14
18
 
15
19
  module ClassMethods
@@ -90,104 +94,102 @@ module Netzke
90
94
 
91
95
  end
92
96
 
93
- module InstanceMethods
94
- # Default config - before applying any passed configuration
95
- def default_config
96
- @default_config ||= {}.merge(weak_default_options).merge(self.class.default_instance_config).merge(self.class.read_inheritable_attribute(:default_config) || {})
97
- end
98
-
99
- # Static, hardcoded config. Consists of default values merged with config that was passed during instantiation
100
- def initial_config
101
- @initial_config ||= default_config.merge(weak_initial_options).merge(@passed_config)
102
- end
97
+ # Default config - before applying any passed configuration
98
+ def default_config
99
+ @default_config ||= {}.merge(weak_default_options).merge(self.class.default_instance_config).merge(self.default_config_attr)
100
+ end
103
101
 
104
- # Config that is not overridden by parents and sessions
105
- def independent_config
106
- @independent_config ||= initial_config.merge(weak_independent_options).merge(initial_config[:persistence] ? persistent_options : {})
107
- end
102
+ # Static, hardcoded config. Consists of default values merged with config that was passed during instantiation
103
+ def initial_config
104
+ @initial_config ||= default_config.merge(weak_initial_options).merge(@passed_config)
105
+ end
108
106
 
109
- def session_config
110
- @session_config ||= independent_config.merge(weak_session_options).merge(session_options)
111
- end
107
+ # Config that is not overridden by parents and sessions
108
+ def independent_config
109
+ @independent_config ||= initial_config.merge(weak_independent_options).merge(initial_config[:persistence] ? persistent_options : {})
110
+ end
112
111
 
113
- # Last level config, overridden only by ineritance
114
- def final_config
115
- @strong_config ||= session_config.merge(weak_final_options).merge(strong_parent_config)
116
- end
112
+ def session_config
113
+ @session_config ||= independent_config.merge(weak_session_options).merge(session_options)
114
+ end
117
115
 
118
- def configuration
119
- final_config
120
- end
116
+ # Last level config, overridden only by ineritance
117
+ def final_config
118
+ @strong_config ||= session_config.merge(weak_final_options).merge(strong_parent_config)
119
+ end
121
120
 
122
- # Resulting config that takes into account all possible ways to configure a component. *Read only*.
123
- # Translates into something like this:
124
- #
125
- # default_config.
126
- # deep_merge(@passed_config).
127
- # deep_merge(persistent_options).
128
- # deep_merge(strong_parent_config).
129
- # deep_merge(strong_session_config)
130
- #
131
- # Moved out to a separate method in order to provide for easy caching.
132
- # *Do not override this method*, use +Base.config+ instead.
133
- def config
134
- @config ||= configuration
135
- end
121
+ def configuration
122
+ final_config
123
+ end
136
124
 
137
- def flat_config(key = nil)
138
- fc = config.flatten_with_type
139
- key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
140
- end
125
+ # Resulting config that takes into account all possible ways to configure a component. *Read only*.
126
+ # Translates into something like this:
127
+ #
128
+ # default_config.
129
+ # deep_merge(@passed_config).
130
+ # deep_merge(persistent_options).
131
+ # deep_merge(strong_parent_config).
132
+ # deep_merge(strong_session_config)
133
+ #
134
+ # Moved out to a separate method in order to provide for easy caching.
135
+ # *Do not override this method*, use +Base.config+ instead.
136
+ def config
137
+ @config ||= configuration
138
+ end
141
139
 
142
- def strong_parent_config
143
- @strong_parent_config ||= parent.nil? ? {} : parent.strong_children_config
144
- end
140
+ def flat_config(key = nil)
141
+ fc = config.flatten_with_type
142
+ key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
143
+ end
145
144
 
146
- def flat_independent_config(key = nil)
147
- fc = independent_config.flatten_with_type
148
- key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
149
- end
145
+ def strong_parent_config
146
+ @strong_parent_config ||= parent.nil? ? {} : parent.strong_children_config
147
+ end
150
148
 
151
- def flat_default_config(key = nil)
152
- fc = default_config.flatten_with_type
153
- key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
154
- end
149
+ def flat_independent_config(key = nil)
150
+ fc = independent_config.flatten_with_type
151
+ key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
152
+ end
155
153
 
156
- def flat_initial_config(key = nil)
157
- fc = initial_config.flatten_with_type
158
- key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
159
- end
154
+ def flat_default_config(key = nil)
155
+ fc = default_config.flatten_with_type
156
+ key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
157
+ end
160
158
 
161
- # Like normal config, but stored in session
162
- # def weak_session_config
163
- # component_session[:weak_session_config] ||= {}
164
- # end
165
- #
166
- # def strong_session_config
167
- # component_session[:strong_session_config] ||= {}
168
- # end
159
+ def flat_initial_config(key = nil)
160
+ fc = initial_config.flatten_with_type
161
+ key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
162
+ end
169
163
 
164
+ # Like normal config, but stored in session
165
+ # def weak_session_config
166
+ # component_session[:weak_session_config] ||= {}
167
+ # end
168
+ #
169
+ # def strong_session_config
170
+ # component_session[:strong_session_config] ||= {}
171
+ # end
170
172
 
171
173
 
172
- # configuration of all children will get deep_merge'd with strong_children_config
173
- # def strong_children_config= (c)
174
- # @strong_children_config = c
175
- # end
176
174
 
177
- # This config will be picked up by all the descendants
178
- def strong_children_config
179
- @strong_children_config ||= parent.nil? ? {} : parent.strong_children_config
180
- end
175
+ # configuration of all children will get deep_merge'd with strong_children_config
176
+ # def strong_children_config= (c)
177
+ # @strong_children_config = c
178
+ # end
181
179
 
182
- # configuration of all children will get reverse_deep_merge'd with weak_children_config
183
- # def weak_children_config= (c)
184
- # @weak_children_config = c
185
- # end
180
+ # This config will be picked up by all the descendants
181
+ def strong_children_config
182
+ @strong_children_config ||= parent.nil? ? {} : parent.strong_children_config
183
+ end
186
184
 
187
- def weak_children_config
188
- @weak_children_config ||= {}
189
- end
185
+ # configuration of all children will get reverse_deep_merge'd with weak_children_config
186
+ # def weak_children_config= (c)
187
+ # @weak_children_config = c
188
+ # end
190
189
 
190
+ def weak_children_config
191
+ @weak_children_config ||= {}
191
192
  end
193
+
192
194
  end
193
195
  end
@@ -3,7 +3,7 @@ module Netzke
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- PATCH = 5
6
+ PATCH = 6
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
9
  end
@@ -14,4 +14,8 @@ class Symbol
14
14
  def component(config = {})
15
15
  config.merge(:netzke_component => self)
16
16
  end
17
+
18
+ def to_cls_attr
19
+ "__#{self}__".to_sym
20
+ end
17
21
  end