multiparameter_assignable_attr 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  About
2
2
  =====
3
3
 
4
- This gem provides a simple patch that allows you to set transient (non-db-backed) model attributes from multiparameter attribute groups (like those passed by date/time select form elements).
4
+ This gem provides a simple patch that allows you to set transient (non-db-backed) model attributes from multiparameter attribute groups (like those passed by date/time select form elements) in Rails.
5
5
 
6
6
  Usage
7
7
  =====
@@ -14,7 +14,7 @@ and run 'bundle install' (or just 'bundle')
14
14
 
15
15
  $ bundle
16
16
 
17
- That's it, you can now mark transient atributes as multiparameter-assignable with the following macro:
17
+ That's it, you can now mark transient attributes as multiparameter-assignable with the following macro:
18
18
 
19
19
  multiparameter_assignable_attr :attribute_name => AttributeClass
20
20
 
@@ -24,8 +24,8 @@ More Info
24
24
  =========
25
25
  Let's say you have a class "Member" and you have added a transient "enrollment_time" attribute to it (perhaps so that you can cleanly place separate date and time inputs in a form for the model). If you have your model definition as follows:
26
26
 
27
- class Member
28
- attr_accessible :name, :email, :enrollment_date
27
+ class Member < ActiveRecord::Base
28
+ attr_accessible :name, :email, :enrollment_date, :enrollment_time
29
29
 
30
30
  attr_accessor :enrollment_time
31
31
 
@@ -35,7 +35,7 @@ Let's say you have a class "Member" and you have added a transient "enrollment_t
35
35
 
36
36
  def merge_enrollment_date_and_time
37
37
  if enrollment_time
38
- self.enrollment_date = self.enrollment_date.change(
38
+ self.enrollment_date = enrollment_date.change(
39
39
  :hour => enrollment_time.hour,
40
40
  :min => enrollment_time.min
41
41
  )
@@ -101,8 +101,8 @@ This error occurs because the value for the transient "start\_time" attribute is
101
101
  This patch just overrides the default implementation of ActiveRecord.reflect\_on\_aggregation to return the appropriate class for indicated transient attributes instead of nil (and defer to super for the other attributes). To use it, we would update our class definition to use the multiparameter\_assignable\_attr macro:
102
102
 
103
103
 
104
- class Member
105
- attr_accessible :name, :email, :enrollment_date
104
+ class Member < ActiveRecord::Base
105
+ attr_accessible :name, :email, :enrollment_date, :enrollment_time
106
106
 
107
107
  multiparameter_assignable_attr :enrollment_time => DateTime
108
108
 
@@ -112,7 +112,7 @@ This patch just overrides the default implementation of ActiveRecord.reflect\_on
112
112
 
113
113
  def merge_enrollment_date_and_time
114
114
  if enrollment_time
115
- self.enrollment_date = self.enrollment_date.change(
115
+ self.enrollment_date = enrollment_date.change(
116
116
  :hour => enrollment_time.hour,
117
117
  :min => enrollment_time.min
118
118
  )
@@ -120,4 +120,4 @@ This patch just overrides the default implementation of ActiveRecord.reflect\_on
120
120
  end
121
121
  end
122
122
 
123
- Now when ActiveRecord looks up the type of Member's "enrollment\_date" attribute via reflect\_on\_aggregation, it will get an OpenStruct with a klass attribute set to DateTime and the assignment from the multiparameter attribute will go forward.
123
+ Now when ActiveRecord looks up the type of Member's "enrollment\_date" attribute via reflect\_on\_aggregation, it will get an OpenStruct with a klass attribute set to DateTime and the assignment from the multiparameter attribute will go forward.
@@ -13,7 +13,7 @@ module ActiveRecordExt
13
13
  @@multiparameter_assignable_attribute_mappings[self].merge!(attr_mappings)
14
14
 
15
15
  code = <<-CODE
16
- attr_accessor :#{attr_mappings.keys.join(', ')}
16
+ attr_accessor #{attr_mappings.keys.map{|k| ":#{k}"}.join(", ")}
17
17
 
18
18
  def self.reflect_on_aggregation(attr_name)
19
19
  if @@multiparameter_assignable_attribute_mappings[self].keys.include?(attr_name)
@@ -1,3 +1,3 @@
1
1
  module MultiparameterAssignableAttr
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -36,3 +36,4 @@ Connecting to database specified by database.yml
36
36
  Connecting to database specified by database.yml
37
37
  Connecting to database specified by database.yml
38
38
  Connecting to database specified by database.yml
39
+ Connecting to database specified by database.yml
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiparameter_assignable_attr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-27 00:00:00.000000000 Z
12
+ date: 2013-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
21
  version: '3.1'
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.1'
30
30
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ">="
36
36
  - !ruby/object:Gem::Version
37
37
  version: '2'
38
38
  type: :runtime
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ">="
44
44
  - !ruby/object:Gem::Version
45
45
  version: '2'
46
46
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :development
@@ -56,7 +56,7 @@ dependencies:
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  description: Patch for multiparameter-wise assignment of transient (non-db-backed)
@@ -121,18 +121,18 @@ require_paths:
121
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
124
- - - ! '>='
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
- - - ! '>='
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
134
  rubyforge_project:
135
- rubygems_version: 1.8.24
135
+ rubygems_version: 1.8.25
136
136
  signing_key:
137
137
  specification_version: 3
138
138
  summary: Patch for multiparameter-wise assignment of transient (non-db-backed) model
@@ -175,3 +175,4 @@ test_files:
175
175
  - test/dummy/script/rails
176
176
  - test/multiparameter_assignable_attr_test.rb
177
177
  - test/test_helper.rb
178
+ has_rdoc: