soulless 0.5.0.rc3 → 0.5.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/soulless/inheritance.rb +18 -7
- data/lib/soulless/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73404dc7c4d37dd5d37a9e9da0b1cbcf4ab270d7
|
4
|
+
data.tar.gz: 3f96ef0fb6469f40839715f5e47694e1ea2a6f0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd7cb188a6bd2073b7800be185d4dfff1fb8a80d906ee8efb6e26aefe2cf9e34a252e7834f1f9cab353297b4f5f69fd1a401aa62a064b243d3f8cd480791f7cc
|
7
|
+
data.tar.gz: 326844e42ebe27522d559ceac30e75357ed362f2cd15395f3632e5ca6dcd7fd6157cc65a7d11f4aad6a668618b17c887d37f4e93163916d765c2f3e5ef842ad5
|
data/README.md
CHANGED
@@ -329,7 +329,9 @@ form.errors.messages # => { name: ["can't be blank"] }
|
|
329
329
|
|
330
330
|
```use_database_default``` - Use the value of the ```default``` migration option as the default value for an attribute. Accepts either a boolean (for all attributes), a string or symbol for a single attribute or an array of strings and symbols for multiple attributes.
|
331
331
|
|
332
|
-
```additional_attributes``` - Used to specify attributes that cannot automatically be added to the form model. These are generally attributes that have been specified using ```attr_accessor```. Accepts a string,
|
332
|
+
```additional_attributes``` - Used to specify attributes that cannot automatically be added to the form model. These are generally attributes that have been specified using ```attr_accessor```. Accepts a string, symbol or an array of strings and symbols for multiple attributes.
|
333
|
+
|
334
|
+
```validate_attribute_on``` - By default any validation that specifies an ```:on``` option will not be inherited. This option will allow you to inherit a validator that uses the ```:on``` with a specific value. Example usage: ```validate_password_on: :create`. Accepts a string or symbol. This option will accept any value that the Rails ```:on``` validator option can accept.
|
333
335
|
|
334
336
|
### I18n
|
335
337
|
|
data/lib/soulless/inheritance.rb
CHANGED
@@ -65,12 +65,14 @@ module Soulless
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def setup_validators(attribute_name, klass, options)
|
68
|
-
return if
|
68
|
+
return if skip_validators?(attribute_name, options) || !include_attribute?(attribute_name, options)
|
69
69
|
klass.validators.each do |validator|
|
70
70
|
if validator.attributes.include?(attribute_name.to_sym)
|
71
71
|
validator_class = validator.class
|
72
72
|
validator_options = {}
|
73
73
|
validator_options.merge!(validator.options)
|
74
|
+
next if validator_options.include?(:on) && options["validate_#{attribute_name}_on".to_sym] != validator_options[:on]
|
75
|
+
validator_options.delete(:on)
|
74
76
|
if validator_class == ActiveRecord::Validations::UniquenessValidator
|
75
77
|
validator_class = Validations::UniquenessValidator
|
76
78
|
validator_options.merge!(model: klass)
|
@@ -87,6 +89,14 @@ module Soulless
|
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
92
|
+
def get_attribute_names(attributes, options)
|
93
|
+
attribute_names = attributes
|
94
|
+
attribute_names << options[:additional_attributes] if options[:additional_attributes]
|
95
|
+
attribute_names.flatten!
|
96
|
+
attribute_names.map!{ |a| a.to_s }
|
97
|
+
attribute_names
|
98
|
+
end
|
99
|
+
|
90
100
|
def translate_primitive(primitive)
|
91
101
|
return nil unless primitive
|
92
102
|
translated_primitive = primitive.to_s.capitalize
|
@@ -112,12 +122,13 @@ module Soulless
|
|
112
122
|
!exclude_attributes.include?(attribute_name) && (only_attributes.empty? || only_attributes.include?(attribute_name))
|
113
123
|
end
|
114
124
|
|
115
|
-
def
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
125
|
+
def skip_validators?(attribute_name, options)
|
126
|
+
return true if options[:skip_validators] == true
|
127
|
+
skip_validators = []
|
128
|
+
skip_validators << options[:skip_validators]
|
129
|
+
skip_validators.flatten!
|
130
|
+
skip_validators.collect!{ |v| v.to_s }
|
131
|
+
skip_validators.include?(attribute_name)
|
121
132
|
end
|
122
133
|
end
|
123
134
|
end
|
data/lib/soulless/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soulless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.0.
|
4
|
+
version: 0.5.0.rc4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Smith
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|