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 +19 -0
- data/CHANGELOG.rdoc +3 -0
- data/README.md +17 -9
- data/Rakefile +6 -2
- data/config/ci/before-travis.sh +11 -0
- data/lib/netzke/actions.rb +5 -8
- data/lib/netzke/base.rb +0 -4
- data/lib/netzke/composition.rb +92 -99
- data/lib/netzke/config_to_dsl_delegator.rb +12 -10
- data/lib/netzke/configuration.rb +82 -80
- data/lib/netzke/core/version.rb +1 -1
- data/lib/netzke/core_ext/symbol.rb +4 -0
- data/lib/netzke/core_ext.rb +2 -1
- data/lib/netzke/inheritance.rb +10 -10
- data/lib/netzke/javascript.rb +92 -79
- data/lib/netzke/plugins.rb +7 -7
- data/lib/netzke/services.rb +7 -8
- data/lib/netzke/stylesheets.rb +6 -8
- data/netzke-core.gemspec +8 -5
- data/test/core_test_app/.powrc +4 -0
- data/test/core_test_app/.rvmrc +1 -1
- data/test/core_test_app/Gemfile +4 -3
- data/test/core_test_app/Gemfile.lock +88 -89
- data/test/core_test_app/config/database.yml.travis +13 -0
- data/test/core_test_app/gemfiles/rails3_1.gemfile +16 -0
- data/test/core_test_app/gemfiles/rails3_2.gemfile +16 -0
- data/test/core_test_app/spec/component/composition_spec.rb +10 -10
- data/test/test_helper.rb +3 -21
- data/test/unit/core_ext_test.rb +1 -13
- data/test/unit/netzke_core_test.rb +1 -1
- metadata +10 -7
- data/test/fixtures/roles.yml +0 -7
- data/test/fixtures/users.yml +0 -9
- data/test/unit/netzke_preference_test.rb +0 -103
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
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Netzke Core
|
2
2
|
|
3
|
-
|
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/
|
21
|
-
* Learn how to build the [Hello World!](https://github.com/
|
22
|
-
* Dive into the [documentation](https://github.com/
|
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/
|
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/
|
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/
|
34
|
-
* [Live-demo](http://demo.netzke.org) (features [Netzke Basepack](https://github.com/
|
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
|
-
|
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
|
+
|
data/lib/netzke/actions.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/netzke/composition.rb
CHANGED
@@ -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
|
-
#
|
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
|
-
|
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
|
-
|
103
|
-
|
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
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
101
|
+
# DEPRECATED in favor of Base.component
|
102
|
+
def initial_components
|
103
|
+
{}
|
104
|
+
end
|
113
105
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
120
|
-
|
121
|
-
|
111
|
+
def eager_loaded_components
|
112
|
+
components.reject{|k,v| v[:lazy_loading]}
|
113
|
+
end
|
122
114
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
115
|
+
# DEPRECATED
|
116
|
+
def add_component(aggr)
|
117
|
+
components.merge!(aggr)
|
118
|
+
end
|
127
119
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
143
|
-
|
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
|
-
|
165
|
-
|
166
|
-
|
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
|
-
|
171
|
-
|
172
|
-
|
164
|
+
eager_loaded_components.keys.each do |aggr|
|
165
|
+
res += component_instance(aggr).dependency_classes
|
166
|
+
end
|
173
167
|
|
174
|
-
|
168
|
+
res += self.class.class_ancestors
|
175
169
|
|
176
|
-
|
177
|
-
|
178
|
-
|
170
|
+
res << self.class
|
171
|
+
res.uniq
|
172
|
+
end
|
179
173
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
174
|
+
# DEPRECATED
|
175
|
+
def js_component(*args)
|
176
|
+
self.class.js_component(*args)
|
177
|
+
end
|
184
178
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
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
|
-
|
222
|
-
|
223
|
-
|
215
|
+
def normalize_components_in_items #:nodoc:
|
216
|
+
normalize_components(config[:items]) if config[:items]
|
217
|
+
end
|
224
218
|
|
225
|
-
|
226
|
-
|
227
|
-
|
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
|
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 =
|
31
|
-
properties.
|
32
|
-
inherited_class.class.send(:define_method,
|
33
|
-
default_config =
|
34
|
-
default_config.merge
|
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
|
data/lib/netzke/configuration.rb
CHANGED
@@ -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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
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
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
-
|
110
|
-
|
111
|
-
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
end
|
112
|
+
def session_config
|
113
|
+
@session_config ||= independent_config.merge(weak_session_options).merge(session_options)
|
114
|
+
end
|
117
115
|
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
123
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
143
|
-
|
144
|
-
|
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
|
-
|
147
|
-
|
148
|
-
|
149
|
-
end
|
145
|
+
def strong_parent_config
|
146
|
+
@strong_parent_config ||= parent.nil? ? {} : parent.strong_children_config
|
147
|
+
end
|
150
148
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
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
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
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
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
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
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
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
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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
|
-
|
188
|
-
|
189
|
-
|
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
|
data/lib/netzke/core/version.rb
CHANGED