custom_fields 1.0.0.beta.19 → 1.0.0.beta.20

Sign up to get free protection for your applications and to get access to all the features.
@@ -91,7 +91,7 @@ module CustomFields
91
91
  def aliased_attributes
92
92
  hash = { :created_at => self.created_at, :updated_at => self.updated_at } rescue {}
93
93
 
94
- self.custom_fields.each do |field|
94
+ (self.custom_fields || []).each do |field|
95
95
  case field.kind
96
96
  when 'file' then hash[field._alias] = self.send(field._name.to_sym).url
97
97
  else
@@ -13,8 +13,9 @@ module CustomFields
13
13
  def apply_date_type(klass)
14
14
 
15
15
  klass.class_eval <<-EOF
16
+
16
17
  def #{self.safe_alias}
17
- self.#{self._name}.strftime(I18n.t('date.formats.default')) rescue nil
18
+ self.#{self._name}
18
19
  end
19
20
 
20
21
  def #{self.safe_alias}=(value)
@@ -25,8 +26,20 @@ module CustomFields
25
26
 
26
27
  self.#{self._name} = value
27
28
  end
29
+
30
+ def formatted_#{self.safe_alias}
31
+ self.#{self._name}.strftime(I18n.t('date.formats.default')) rescue nil
32
+ end
33
+
34
+ alias formatted_#{self.safe_alias}= #{self.safe_alias}=
28
35
  EOF
29
36
 
37
+ def add_date_validation(klass)
38
+ if self.required?
39
+ klass.validates_presence_of self.safe_alias.to_sym, :"formatted_#{self.safe_alias}"
40
+ end
41
+ end
42
+
30
43
  end
31
44
 
32
45
  end
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module CustomFields
3
- VERSION = "1.0.0.beta.19"
3
+ VERSION = "1.0.0.beta.20"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: custom_fields
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196389
4
+ hash: 62196395
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
10
  - beta
11
- - 19
12
- version: 1.0.0.beta.19
11
+ - 20
12
+ version: 1.0.0.beta.20
13
13
  platform: ruby
14
14
  authors:
15
15
  - Didier Lafforgue
@@ -17,10 +17,12 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-06-21 00:00:00 -07:00
21
- default_executable:
20
+ date: 2011-07-01 00:00:00 Z
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
23
+ name: mongoid
24
+ prerelease: false
25
+ type: :runtime
24
26
  version_requirements: &id001 !ruby/object:Gem::Requirement
25
27
  none: false
26
28
  requirements:
@@ -32,11 +34,11 @@ dependencies:
32
34
  - 0
33
35
  - 2
34
36
  version: 2.0.2
35
- prerelease: false
36
37
  requirement: *id001
37
- type: :runtime
38
- name: mongoid
39
38
  - !ruby/object:Gem::Dependency
39
+ name: activesupport
40
+ prerelease: false
41
+ type: :runtime
40
42
  version_requirements: &id002 !ruby/object:Gem::Requirement
41
43
  none: false
42
44
  requirements:
@@ -48,10 +50,7 @@ dependencies:
48
50
  - 0
49
51
  - 7
50
52
  version: 3.0.7
51
- prerelease: false
52
53
  requirement: *id002
53
- type: :runtime
54
- name: activesupport
55
54
  description: Manage custom fields to a mongoid document or a collection. This module is one of the core features we implemented in our custom cms named Locomotive.
56
55
  email:
57
56
  - didier@nocoffee.fr
@@ -88,7 +87,6 @@ files:
88
87
  - config/locales/en.yml
89
88
  - config/locales/fr.yml
90
89
  - config/locales/pt-BR.yml
91
- has_rdoc: true
92
90
  homepage: http://github.com/locomotivecms/custom_fields
93
91
  licenses: []
94
92
 
@@ -120,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
118
  requirements: []
121
119
 
122
120
  rubyforge_project: nowarning
123
- rubygems_version: 1.6.2
121
+ rubygems_version: 1.8.5
124
122
  signing_key:
125
123
  specification_version: 3
126
124
  summary: Custom fields extension for Mongoid