Module: Schema
- Included in:
- Controls::Schema::Boolean::Example, Controls::Schema::Check::Example, Controls::Schema::DefaultValue::Example, Controls::Schema::Duplicate::Example, Controls::Schema::Equivalent::Example, Controls::Schema::TransientAttributes::Example, Controls::Schema::Typed::Example, Controls::Schema::Validation::Example
- Defined in:
- lib/schema/schema.rb,
lib/schema/data_structure.rb,
lib/schema/schema/compare.rb,
lib/schema/controls/random.rb,
lib/schema/controls/schema.rb,
lib/schema/schema/attribute.rb,
lib/schema/validation/error.rb,
lib/schema/controls/attribute.rb,
lib/schema/controls/comparison.rb,
lib/schema/controls/data_structure.rb,
lib/schema/controls/comparison/entry.rb,
lib/schema/controls/schema/different.rb,
lib/schema/schema/compare/comparison.rb,
lib/schema/validation/nil_attributes.rb,
lib/schema/schema/compare/comparison/entry.rb
Defined Under Namespace
Modules: AttributeMacro, Attributes, Boolean, Compare, Controls, DataStructure, Info, Validation
Classes: Attribute, AttributeRegistry, Error
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(cls) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/schema/schema.rb', line 4
def self.included(cls)
cls.class_exec do
extend Info
extend AttributeMacro
extend Attributes
include TemplateMethod
template_method :transform_write do |data|
transform_out(data)
end
template_method :transform_out
const_set(:Boolean, Boolean)
end
end
|
Instance Method Details
#==(other, attributes_names = nil, ignore_class: nil) ⇒ Object
Also known as:
eql?
187
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/schema/schema.rb', line 187
def ==(other, attributes_names=nil, ignore_class: nil)
ignore_class ||= false
if not ignore_class
return false if self.class != other.class
end
comparison = Compare.(self, other, attributes_names)
different = comparison.different?(ignore_class: ignore_class)
!different
end
|
#all_attributes ⇒ Object
183
184
185
|
# File 'lib/schema/schema.rb', line 183
def all_attributes
attributes(include_transient: true)
end
|
#attributes(include_transient: nil) ⇒ Object
167
168
169
170
171
172
173
174
175
176
177
|
# File 'lib/schema/schema.rb', line 167
def attributes(include_transient: nil)
include_transient ||= false
attribute_names = self.class.attribute_names(include_transient: include_transient)
data = get_attributes(attribute_names)
transform_write(data)
data
end
|
#get_attributes(attribute_names) ⇒ Object
161
162
163
164
165
|
# File 'lib/schema/schema.rb', line 161
def get_attributes(attribute_names)
attribute_names.each_with_object({}) do |attribute_name, attributes|
attributes[attribute_name] = public_send(attribute_name)
end
end
|
#hash ⇒ Object
202
203
204
|
# File 'lib/schema/schema.rb', line 202
def hash
[self.class, raw_attributes].hash
end
|
#raw_attributes ⇒ Object
156
157
158
159
|
# File 'lib/schema/schema.rb', line 156
def raw_attributes
all_attribute_names = self.class.all_attribute_names
get_attributes(all_attribute_names)
end
|
#to_h ⇒ Object
179
180
181
|
# File 'lib/schema/schema.rb', line 179
def to_h
attributes
end
|