acts_as_configuration 0.0.2.r1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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.config.private_photos = true
28
- user.config.subscribe_to_news = false
29
- user.config.perfil_description = ''
27
+ user.configuration.private_photos = true
28
+ user.configuration.subscribe_to_news = false
29
+ user.configuration.perfil_description = ''
30
30
  user.save
31
31
 
32
32
  ### Columns configuration
@@ -126,10 +126,57 @@ 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
+
129
158
  class_eval <<-EOV
130
159
  public
131
160
  validate :aac_validations
132
161
 
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
+
133
180
  def #{column_name.to_s}
134
181
  if not @#{column_name.to_s}_configuration.kind_of? ActsAsConfiguration::Configuration
135
182
  opts = initialize_options(#{options})
@@ -275,8 +322,11 @@ module ActsAsConfiguration
275
322
  end
276
323
  end
277
324
  EOV
325
+
278
326
  end
279
327
 
328
+
329
+
280
330
  protected
281
331
 
282
332
 
@@ -1,3 +1,3 @@
1
1
  module ActsAsConfiguration
2
- VERSION = "0.0.2.r1"
2
+ VERSION = "0.0.2"
3
3
  end
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.2.r1
5
- prerelease: 6
4
+ version: 0.0.2
5
+ prerelease:
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-31 00:00:00.000000000 Z
12
+ date: 2011-12-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &8907620 !ruby/object:Gem::Requirement
16
+ requirement: &15461660 !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: *8907620
24
+ version_requirements: *15461660
25
25
  description: Make a variable to work like a configuration variable
26
26
  email:
27
27
  - andres.b.dev@gmail.com
@@ -53,9 +53,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
53
  required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
- - - ! '>'
56
+ - - ! '>='
57
57
  - !ruby/object:Gem::Version
58
- version: 1.3.1
58
+ version: '0'
59
59
  requirements: []
60
60
  rubyforge_project: acts_as_configuration
61
61
  rubygems_version: 1.8.11