Class: ABBYY::Cloud::Model
- Inherits:
-
Object
- Object
- ABBYY::Cloud::Model
show all
- Extended by:
- Dry::Initializer::Mixin
- Defined in:
- lib/abbyy/cloud/model.rb
Direct Known Subclasses
ABBYY::Cloud::Models::Direction, ABBYY::Cloud::Models::Discount, ABBYY::Cloud::Models::Engine, ABBYY::Cloud::Models::Error, ABBYY::Cloud::Models::FileReference, ABBYY::Cloud::Models::FullOrder, ABBYY::Cloud::Models::OcrSettings, ABBYY::Cloud::Models::OcrStatistics, ABBYY::Cloud::Models::OcrWarning, ABBYY::Cloud::Models::OrderStatistics, ABBYY::Cloud::Models::Price, ABBYY::Cloud::Models::SourceSegment, ABBYY::Cloud::Models::SourceTag, ABBYY::Cloud::Models::TextStatistics, ABBYY::Cloud::Models::TransferData, ABBYY::Cloud::Models::Translation, ABBYY::Cloud::Models::TranslationLink, ABBYY::Cloud::Models::TranslationSegment, ABBYY::Cloud::Models::UnitPrice
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.new(value) ⇒ Object
Also known as:
call, []
16
17
18
19
20
21
22
|
# File 'lib/abbyy/cloud/model.rb', line 16
def new(value)
return value if value.is_a? self
value = value.to_h.each_with_object({}) do |(key, val), obj|
obj[key.to_sym] = val
end
super value
end
|
Instance Method Details
#==(other) ⇒ Object
29
30
31
32
|
# File 'lib/abbyy/cloud/model.rb', line 29
def ==(other)
return false unless other.respond_to? :to_h
to_h == other.to_h
end
|
#to_h ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/abbyy/cloud/model.rb', line 34
def to_h
attributes = method(:initialize)
.parameters
.map { |item| item[1] unless item[0] == :keyrest }.compact
attributes.each_with_object({}) do |key, hash|
val = send(key)
hash[key] = hashify(val) unless val == Dry::Initializer::UNDEFINED
end
end
|