evt-schema 1.0.0.0 → 1.0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1257def39aac8062b7200ec50dd0a926f5b5f3f422183c29686709cf95c0889e
4
- data.tar.gz: cbc2d13b0aaaa8ee70dd0b071552825ea6a705249bef14dabeb8194d8d262821
3
+ metadata.gz: b28f918ca687069fb8873fd2beb3adbabf9b94d38970ce215d79e58b85d52bbc
4
+ data.tar.gz: cac22a2b6d9098a5525d9ac1ccf6c0130c5c016c39703b1414981184831701d8
5
5
  SHA512:
6
- metadata.gz: 685ab2dcc6d43e992660dabdabe07226f2ebe470c25f1cb60bdeb086f56752e2a00c9382029e9d2eb564f653fae04b52ebaadae314e70ffccc176549b17987c5
7
- data.tar.gz: 7c6c26687ac9fcd1544a37425b9cdb8ba89b9b8a5f7d43761c6f16cd023558875933864d401a3aff3b051d69ea1806513f36865db519af71f75c7ab840a6fae6
6
+ metadata.gz: 7ea3009dc43e0538e4fff15a952825553c1b1574d5782c568b9b3a88691c8bfa43db1c2c11de261627762df4a04498383e6777c25b8bcc919cace1438a3df155
7
+ data.tar.gz: e78f28d4541fa257ea873691e07668d2be493af76fb6ca7cadb1f36c96e793a970d6581c2c3271bc053fe067182296ab5294b4b6d912321224407e4382f101fa
@@ -16,7 +16,9 @@ module Schema
16
16
  end
17
17
 
18
18
  def self.hash
19
- example.to_h
19
+ {
20
+ some_attribute: 'some value'
21
+ }
20
22
  end
21
23
 
22
24
  class Example
@@ -48,6 +50,32 @@ module Schema
48
50
  end
49
51
  end
50
52
  end
53
+
54
+ module ImportAndExport
55
+ def self.example
56
+ example = Example.new
57
+ example.some_attribute = 'some value'
58
+ example
59
+ end
60
+
61
+ class Example < DataStructure::Example
62
+ def import(data)
63
+ data[:some_attribute] = 'some imported value'
64
+ end
65
+
66
+ def export(data)
67
+ data[:some_attribute] = 'some exported value'
68
+ end
69
+ end
70
+
71
+ module Data
72
+ def self.example
73
+ {
74
+ some_attribute: 'some value'
75
+ }
76
+ end
77
+ end
78
+ end
51
79
  end
52
80
  end
53
81
  end
@@ -10,6 +10,7 @@ module Schema
10
10
  virtual :configure_dependencies do
11
11
  configure
12
12
  end
13
+ virtual :import
13
14
  end
14
15
  end
15
16
 
@@ -19,6 +20,7 @@ module Schema
19
20
  strict ||= false
20
21
 
21
22
  new.tap do |instance|
23
+ instance.import(data)
22
24
  set_attributes(instance, data, strict)
23
25
  instance.configure_dependencies
24
26
  end
@@ -6,6 +6,13 @@ module Schema
6
6
  extend AttributeMacro
7
7
  extend Attributes
8
8
 
9
+ # This is done as a countermeasure for incompatibility
10
+ # between Virtual and an Assertions module
11
+ # include Virtual
12
+ # virtual :export
13
+ define_method(:export) {|data|}
14
+ #
15
+
9
16
  const_set(:Boolean, Boolean)
10
17
  end
11
18
  end
@@ -143,10 +150,14 @@ module Schema
143
150
  transient_attributes = self.class.transient_attributes
144
151
  end
145
152
 
146
- self.class.attributes.each_with_object({}) do |attribute, attributes|
153
+ data = self.class.attributes.each_with_object({}) do |attribute, attributes|
147
154
  next if transient_attributes.include?(attribute.name)
148
155
  attributes[attribute.name] = public_send(attribute.name)
149
156
  end
157
+
158
+ export(data)
159
+
160
+ data
150
161
  end
151
162
  alias :to_h :attributes
152
163
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.0
4
+ version: 1.0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-04 00:00:00.000000000 Z
11
+ date: 2019-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: evt-attribute
@@ -115,8 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubyforge_project:
119
- rubygems_version: 2.7.6
118
+ rubygems_version: 3.0.1
120
119
  signing_key:
121
120
  specification_version: 4
122
121
  summary: Primitives for schema and data structure