Module: Schema
- Included in:
- Controls::Schema::Boolean::Example, Controls::Schema::DefaultValue::Example, Controls::Schema::Duplicate::Example, Controls::Schema::Equivalent::Example, Controls::Schema::TransientAttributes::Example, Controls::Schema::Typed::Example, Controls::Schema::Typed::Strict::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?
200
201
202
203
204
205
206
207
208
209
210
211
212
|
# File 'lib/schema/schema.rb', line 200
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
196
197
198
|
# File 'lib/schema/schema.rb', line 196
def all_attributes
attributes(include_transient: true)
end
|
#attributes(include_transient: nil) ⇒ Object
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/schema/schema.rb', line 180
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
174
175
176
177
178
|
# File 'lib/schema/schema.rb', line 174
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
215
216
217
|
# File 'lib/schema/schema.rb', line 215
def hash
[self.class, raw_attributes].hash
end
|
#raw_attributes ⇒ Object
169
170
171
172
|
# File 'lib/schema/schema.rb', line 169
def raw_attributes
all_attribute_names = self.class.all_attribute_names
get_attributes(all_attribute_names)
end
|
#to_h ⇒ Object
192
193
194
|
# File 'lib/schema/schema.rb', line 192
def to_h
attributes
end
|