Class: Printavo::Models::Base
- Inherits:
-
Object
- Object
- Printavo::Models::Base
show all
- Defined in:
- lib/printavo/models/base.rb
Direct Known Subclasses
Account, ApprovalRequest, Category, Contact, ContractorProfile, CustomAddress, Customer, DeliveryMethod, EmailTemplate, Expense, Fee, Imprint, Inquiry, Invoice, Job, LineItem, LineItemGroup, Printavo::MerchOrder, Printavo::MerchStore, Printavo::Mockup, Order, Payment, PaymentRequest, PaymentTerm, PresetTask, PresetTaskGroup, PricingMatrix, Product, ProductionFile, Status, Task, Thread, Transaction, TransactionPayment, TypeOfWork, User, Vendor
Instance Method Summary
collapse
Constructor Details
#initialize(attributes = {}) ⇒ Base
Returns a new instance of Base.
7
8
9
|
# File 'lib/printavo/models/base.rb', line 7
def initialize(attributes = {})
@attributes = (attributes || {}).transform_keys(&:to_s)
end
|
Instance Method Details
#==(other) ⇒ Object
27
28
29
|
# File 'lib/printavo/models/base.rb', line 27
def ==(other)
other.is_a?(self.class) && other.to_h == to_h
end
|
#[](key) ⇒ Object
11
12
13
|
# File 'lib/printavo/models/base.rb', line 11
def [](key)
@attributes[key.to_s]
end
|
#dig(*keys) ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/printavo/models/base.rb', line 15
def dig(*keys)
keys.map(&:to_s).reduce(@attributes) do |obj, key|
break nil unless obj.is_a?(Hash)
obj[key]
end
end
|
#inspect ⇒ Object
31
32
33
|
# File 'lib/printavo/models/base.rb', line 31
def inspect
"#<#{self.class.name} #{@attributes.inspect}>"
end
|
#to_h ⇒ Object
23
24
25
|
# File 'lib/printavo/models/base.rb', line 23
def to_h
@attributes.dup
end
|