spira 0.0.12 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +2 -0
- data/CHANGES.md +6 -3
- data/{README → README.md} +91 -120
- data/lib/rdf/ext/uri.rb +37 -0
- data/lib/spira.rb +47 -86
- data/lib/spira/association_reflection.rb +25 -0
- data/lib/spira/base.rb +353 -4
- data/lib/spira/exceptions.rb +13 -7
- data/lib/spira/persistence.rb +531 -0
- data/lib/spira/reflections.rb +19 -0
- data/lib/spira/resource.rb +165 -60
- data/lib/spira/serialization.rb +27 -0
- data/lib/spira/type.rb +7 -7
- data/lib/spira/types.rb +8 -11
- data/lib/spira/types/boolean.rb +3 -3
- data/lib/spira/types/date.rb +4 -5
- data/lib/spira/types/dateTime.rb +26 -0
- data/lib/spira/types/decimal.rb +2 -2
- data/lib/spira/types/float.rb +3 -3
- data/lib/spira/types/gYear.rb +26 -0
- data/lib/spira/types/int.rb +27 -0
- data/lib/spira/types/integer.rb +3 -3
- data/lib/spira/types/long.rb +27 -0
- data/lib/spira/types/negativeInteger.rb +27 -0
- data/lib/spira/types/nonNegativeInteger.rb +27 -0
- data/lib/spira/types/nonPositiveInteger.rb +27 -0
- data/lib/spira/types/positiveInteger.rb +27 -0
- data/lib/spira/types/string.rb +1 -1
- data/lib/spira/utils.rb +29 -0
- data/lib/spira/validations.rb +77 -0
- data/lib/spira/validations/uniqueness.rb +33 -0
- data/lib/spira/version.rb +3 -6
- metadata +218 -123
- data/lib/spira/errors.rb +0 -94
- data/lib/spira/extensions.rb +0 -14
- data/lib/spira/resource/class_methods.rb +0 -260
- data/lib/spira/resource/dsl.rb +0 -279
- data/lib/spira/resource/instance_methods.rb +0 -567
- data/lib/spira/resource/validations.rb +0 -47
@@ -1,47 +0,0 @@
|
|
1
|
-
module Spira
|
2
|
-
module Resource
|
3
|
-
|
4
|
-
##
|
5
|
-
# Instance methods relating to validations for a Spira resource. This
|
6
|
-
# includes the default assertions.
|
7
|
-
#
|
8
|
-
# @see Spira::Resource::InstanceMethods
|
9
|
-
# @see Spira::Resource::ClassMethods
|
10
|
-
# @see Spira::Resource::DSL
|
11
|
-
module Validations
|
12
|
-
|
13
|
-
##
|
14
|
-
# Assert a fact about this instance. If the given expression is false,
|
15
|
-
# an error will be noted.
|
16
|
-
#
|
17
|
-
# @example Assert that a title is correct
|
18
|
-
# assert(title == 'xyz', :title, 'bad title')
|
19
|
-
# @param [Any] boolean The expression to evaluate
|
20
|
-
# @param [Symbol] property The property or has_many to mark as incorrect on failure
|
21
|
-
# @param [String] message The message to record if this assertion fails
|
22
|
-
# @return [Void]
|
23
|
-
def assert(boolean, property, message)
|
24
|
-
errors.add(property, message) unless boolean
|
25
|
-
end
|
26
|
-
|
27
|
-
##
|
28
|
-
# A default helper assertion. Asserts that a given property is set.
|
29
|
-
#
|
30
|
-
# @param [Symbol] name The property to check
|
31
|
-
# @return [Void]
|
32
|
-
def assert_set(name)
|
33
|
-
assert(!(self.send(name).nil?), name, "#{name.to_s} cannot be nil")
|
34
|
-
end
|
35
|
-
|
36
|
-
##
|
37
|
-
# A default helper assertion. Asserts that a given property is numeric.
|
38
|
-
#
|
39
|
-
# @param [Symbol] name The property to check
|
40
|
-
# @return [Void]
|
41
|
-
def assert_numeric(name)
|
42
|
-
assert(self.send(name).is_a?(Numeric), name, "#{name.to_s} must be numeric (was #{self.send(name)})")
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|