evt-schema 0.6.0.3 → 0.6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/schema/controls/schema.rb +23 -0
- data/lib/schema/schema.rb +24 -3
- 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: 92227fc032ede4ae3eccd9ed38ebc973c1b94689
|
4
|
+
data.tar.gz: 02b9938d47034e608fc1046e0b5197effa04907d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 893ce1d90dba0c0607d38d08ba9dd0a8ac19a04036d553407a6bf436bf70672e2dcfd540f13bba6b8be943c96338d758d3f2ac4294242a7f23be633ae99910a9
|
7
|
+
data.tar.gz: 6a5984d06f16a321edf3768089ec2c1413df1abd04fade078f072692efbaa93f9ea0981187397822e934c15b7ecca67dac96ec4a310ee76400b835be3a0704fb
|
@@ -36,6 +36,29 @@ module Schema
|
|
36
36
|
class OtherExample < Example
|
37
37
|
end
|
38
38
|
|
39
|
+
module TransientAttributes
|
40
|
+
def self.example
|
41
|
+
example = Example.new
|
42
|
+
example.some_attribute = 'some value'
|
43
|
+
example.some_other_attribute = 'some other value'
|
44
|
+
example.yet_another_attribute = 'yet another value'
|
45
|
+
example
|
46
|
+
end
|
47
|
+
|
48
|
+
class Example
|
49
|
+
include ::Schema
|
50
|
+
attribute :some_attribute
|
51
|
+
attribute :some_other_attribute
|
52
|
+
attribute :yet_another_attribute
|
53
|
+
|
54
|
+
def self.transient_attributes
|
55
|
+
[
|
56
|
+
:yet_another_attribute
|
57
|
+
]
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
39
62
|
module Equivalent
|
40
63
|
def self.example
|
41
64
|
example = Example.new
|
data/lib/schema/schema.rb
CHANGED
@@ -4,7 +4,7 @@ module Schema
|
|
4
4
|
def self.included(cls)
|
5
5
|
cls.class_exec do
|
6
6
|
extend AttributeMacro
|
7
|
-
extend
|
7
|
+
extend Attributes
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -44,13 +44,24 @@ module Schema
|
|
44
44
|
alias :attribute :attribute_macro
|
45
45
|
end
|
46
46
|
|
47
|
-
module
|
47
|
+
module Attributes
|
48
48
|
def attributes
|
49
49
|
@attributes ||= AttributeRegistry.new
|
50
50
|
end
|
51
51
|
|
52
52
|
def attribute_names
|
53
|
-
|
53
|
+
transient_attributes = []
|
54
|
+
if respond_to?(:transient_attributes)
|
55
|
+
transient_attributes = self.transient_attributes
|
56
|
+
end
|
57
|
+
|
58
|
+
attribute_names = []
|
59
|
+
attributes.each do |attribute|
|
60
|
+
next if transient_attributes.include?(attribute.name)
|
61
|
+
attribute_names << attribute.name
|
62
|
+
end
|
63
|
+
|
64
|
+
attribute_names
|
54
65
|
end
|
55
66
|
end
|
56
67
|
|
@@ -72,6 +83,10 @@ module Schema
|
|
72
83
|
entries.map(&action)
|
73
84
|
end
|
74
85
|
|
86
|
+
def each(&action)
|
87
|
+
entries.each(&action)
|
88
|
+
end
|
89
|
+
|
75
90
|
def each_with_object(obj, &action)
|
76
91
|
entries.each_with_object(obj, &action)
|
77
92
|
end
|
@@ -102,7 +117,13 @@ module Schema
|
|
102
117
|
end
|
103
118
|
|
104
119
|
def attributes
|
120
|
+
transient_attributes = []
|
121
|
+
if self.class.respond_to?(:transient_attributes)
|
122
|
+
transient_attributes = self.class.transient_attributes
|
123
|
+
end
|
124
|
+
|
105
125
|
self.class.attributes.each_with_object({}) do |attribute, attributes|
|
126
|
+
next if transient_attributes.include?(attribute.name)
|
106
127
|
attributes[attribute.name] = public_send(attribute.name)
|
107
128
|
end
|
108
129
|
end
|
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: 0.6.0
|
4
|
+
version: 0.6.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:
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: evt-attribute
|