schemad 1.2.2 → 1.2.3
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.
- checksums.yaml +4 -4
- data/.travis.yml +13 -10
- data/lib/schemad/entity.rb +3 -6
- data/lib/schemad/extensions.rb +7 -0
- data/lib/schemad/normalizer.rb +5 -2
- data/lib/schemad/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c365fd42508eefbf5df2f46504c0a12ecdda0a02
|
4
|
+
data.tar.gz: 72dc0e423ede9244418d7c1df9a3405d51b2ccfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e6b7c4c4557ed40b1ae2236b032ec9e24c6c33741ea979c641bca682ac4c1305eb3596a85151830be4a54ce4ddbb129325c653c162020a9af76e71a6a234af1
|
7
|
+
data.tar.gz: 31e85397afe6b80b73ad7f3894ee12402f24c0e3e34ed99da6037f7499fff0ceb2672ce7927c5d07bf967fa92012e61f69737f29953ec05b00dce011544645aa
|
data/.travis.yml
CHANGED
@@ -1,14 +1,17 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0
|
5
|
+
- 2.1
|
6
|
+
- 2.2
|
7
|
+
- rbx
|
8
|
+
- jruby-19mode
|
9
9
|
matrix:
|
10
10
|
allow_failures:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
script: bundle exec rake spec
|
11
|
+
- rvm: 1.9.3
|
12
|
+
- rvm: rbx
|
13
|
+
- rvm: jruby-19mode
|
14
|
+
script: bundle exec rake spec
|
15
|
+
env:
|
16
|
+
global:
|
17
|
+
secure: oXespZsV0esupERqRSdJe6WMV4pyUtRUxKqgZZ7+lHDiLf0rUfXeJ96atyqHF293C7oApAkyoM6Lf92Vw5wDJJzdghuDMMa+e18ilHHGD0eDUB3MfDCuj6oHdCTxYs5q9L0rGPTkUcx+EVw3PeFe9CDaWHhIkvosfrdzXf9volU=
|
data/lib/schemad/entity.rb
CHANGED
@@ -3,10 +3,11 @@ require 'schemad/type_handler'
|
|
3
3
|
|
4
4
|
module Schemad
|
5
5
|
class Entity
|
6
|
-
|
6
|
+
include Schemad::Extensions
|
7
7
|
|
8
8
|
def self.inherited(subclass)
|
9
|
-
|
9
|
+
default_attrs = inherited_var(:@attributes, [])
|
10
|
+
subclass.instance_variable_set(:@attributes, default_attrs)
|
10
11
|
end
|
11
12
|
|
12
13
|
def self.attribute(name, args={}, &block)
|
@@ -45,10 +46,6 @@ module Schemad
|
|
45
46
|
alias_method :attributes, :to_hash
|
46
47
|
|
47
48
|
private
|
48
|
-
def self.inherited_attrs
|
49
|
-
parent_attrs = self.instance_variable_get(:@attributes)
|
50
|
-
default_attrs = (parent_attrs ? parent_attrs.dup : [])
|
51
|
-
end
|
52
49
|
|
53
50
|
def self.define_parser_for(name, args, &block)
|
54
51
|
define_method "parse_#{name}" do |data|
|
data/lib/schemad/extensions.rb
CHANGED
@@ -11,6 +11,11 @@ module Schemad
|
|
11
11
|
def base_class_name
|
12
12
|
name.demodulize
|
13
13
|
end
|
14
|
+
|
15
|
+
def inherited_var(attr_name, default)
|
16
|
+
parent_attrs = self.instance_variable_get(attr_name)
|
17
|
+
default_attrs = (parent_attrs ? parent_attrs.dup : default)
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
def base_class_name
|
@@ -35,5 +40,7 @@ module Schemad
|
|
35
40
|
def indifferent_hash(hash)
|
36
41
|
ActiveSupport::HashWithIndifferentAccess.new hash
|
37
42
|
end
|
43
|
+
|
44
|
+
|
38
45
|
end
|
39
46
|
end
|
data/lib/schemad/normalizer.rb
CHANGED
@@ -9,8 +9,11 @@ module Schemad
|
|
9
9
|
InvalidPath = Class.new(Exception)
|
10
10
|
|
11
11
|
def self.inherited(subclass)
|
12
|
-
|
13
|
-
subclass.instance_variable_set(:@
|
12
|
+
default_normalizers = inherited_var(:@normalizers, {})
|
13
|
+
subclass.instance_variable_set(:@normalizers, default_normalizers)
|
14
|
+
|
15
|
+
default_allowed = inherited_var(:@allowed_attributes, [])
|
16
|
+
subclass.instance_variable_set(:@allowed_attributes, default_allowed)
|
14
17
|
end
|
15
18
|
|
16
19
|
def self.include_fields(*fields)
|
data/lib/schemad/version.rb
CHANGED