acts_as_configuration 0.0.1 → 0.0.2.r1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-license.txt +23 -0
- data/README.markdown +3 -3
- data/lib/acts_as_configuration/version.rb +1 -1
- data/lib/acts_as_configuration.rb +0 -50
- metadata +8 -7
data/MIT-license.txt
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Copyright (c) 2011 Andrés Borek
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any
|
4
|
+
person obtaining a copy of this software and associated
|
5
|
+
documentation files (the "Software"), to deal in the
|
6
|
+
Software without restriction, including without limitation
|
7
|
+
the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the
|
9
|
+
Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice
|
13
|
+
shall be included in all copies or substantial portions of
|
14
|
+
the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
|
17
|
+
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
18
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
19
|
+
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
|
20
|
+
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
21
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
22
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
23
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
CHANGED
@@ -24,9 +24,9 @@ For example:
|
|
24
24
|
|
25
25
|
Now you can write your configuration like:
|
26
26
|
|
27
|
-
user.
|
28
|
-
user.
|
29
|
-
user.
|
27
|
+
user.config.private_photos = true
|
28
|
+
user.config.subscribe_to_news = false
|
29
|
+
user.config.perfil_description = ''
|
30
30
|
user.save
|
31
31
|
|
32
32
|
### Columns configuration
|
@@ -126,57 +126,10 @@ module ActsAsConfiguration
|
|
126
126
|
|
127
127
|
module ClassMethods
|
128
128
|
def acts_as_configuration(column_name, options = {})
|
129
|
-
cattr_accessor :aac_columns_config
|
130
|
-
self.aac_columns_config = self.aac_columns_config || {}
|
131
|
-
|
132
|
-
# Parse options
|
133
|
-
# Definir attr_accessor
|
134
|
-
# definir cattr_accessor
|
135
|
-
# Realizar un include que redefina el initialize
|
136
|
-
# Ver https://github.com/Caseproof/metafy/blob/master/lib/metafy/activerecord_methods.rb
|
137
|
-
|
138
|
-
# Para ver que hacer en el initialize ver:
|
139
|
-
# https://github.com/Caseproof/metafy/blob/master/lib/metafy/base.rb
|
140
|
-
|
141
|
-
assign_attributes_eval = "
|
142
|
-
def assign_attributes(attributes = nil, options = {})
|
143
|
-
attributes.each_pair do |key, value|
|
144
|
-
puts key
|
145
|
-
if key.to_s =~ /^#{column_name}_/
|
146
|
-
puts key
|
147
|
-
rb = \"#{column_name}.\#\{key.to_s.gsub(/^#{column_name}_/,'')\}\"
|
148
|
-
eval rb, binding
|
149
|
-
end
|
150
|
-
end
|
151
|
-
attributes.delete_if do |key,value|
|
152
|
-
key.to_s =~ /^#{column_name}_/
|
153
|
-
end
|
154
|
-
super attributes, options
|
155
|
-
end
|
156
|
-
"
|
157
|
-
|
158
129
|
class_eval <<-EOV
|
159
130
|
public
|
160
131
|
validate :aac_validations
|
161
132
|
|
162
|
-
puts "Evaluando de: \#\{self.name}"
|
163
|
-
(eval self.name).class_eval <<-EOS
|
164
|
-
def assign_attributes(attributes = nil, options = {})
|
165
|
-
attributes.each_pair do |key, value|
|
166
|
-
puts key
|
167
|
-
if key.to_s =~ /^#{column_name}_/
|
168
|
-
puts key
|
169
|
-
rb = \"#{column_name}.\#\{key.to_s.gsub(/^#{column_name}_/,'')\}\"
|
170
|
-
eval rb, binding
|
171
|
-
end
|
172
|
-
end
|
173
|
-
attributes.delete_if do |key,value|
|
174
|
-
key.to_s =~ /^#{column_name}_/
|
175
|
-
end
|
176
|
-
super attributes, options
|
177
|
-
end
|
178
|
-
EOS
|
179
|
-
|
180
133
|
def #{column_name.to_s}
|
181
134
|
if not @#{column_name.to_s}_configuration.kind_of? ActsAsConfiguration::Configuration
|
182
135
|
opts = initialize_options(#{options})
|
@@ -322,11 +275,8 @@ module ActsAsConfiguration
|
|
322
275
|
end
|
323
276
|
end
|
324
277
|
EOV
|
325
|
-
|
326
278
|
end
|
327
279
|
|
328
|
-
|
329
|
-
|
330
280
|
protected
|
331
281
|
|
332
282
|
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_configuration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2.r1
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andrés B.
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &8907620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *8907620
|
25
25
|
description: Make a variable to work like a configuration variable
|
26
26
|
email:
|
27
27
|
- andres.b.dev@gmail.com
|
@@ -31,6 +31,7 @@ extra_rdoc_files: []
|
|
31
31
|
files:
|
32
32
|
- .gitignore
|
33
33
|
- Gemfile
|
34
|
+
- MIT-license.txt
|
34
35
|
- README
|
35
36
|
- README.markdown
|
36
37
|
- Rakefile
|
@@ -52,9 +53,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
54
|
none: false
|
54
55
|
requirements:
|
55
|
-
- - ! '
|
56
|
+
- - ! '>'
|
56
57
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
+
version: 1.3.1
|
58
59
|
requirements: []
|
59
60
|
rubyforge_project: acts_as_configuration
|
60
61
|
rubygems_version: 1.8.11
|