Module: PayuZa::Structs::StructModel
- Included in:
- AdditionalInformation, Basket, CreditCard, CustomField, Customer, GetTransaction, Transaction
- Defined in:
- lib/payu_za/structs/struct_model.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
5 6 7 |
# File 'lib/payu_za/structs/struct_model.rb', line 5 def self.included(base) base.send(:extend, ClassMethods) end |
Instance Method Details
#operation_name ⇒ Object
25 26 27 |
# File 'lib/payu_za/structs/struct_model.rb', line 25 def operation_name @operation_name ||= self.class.name.split('::').last.underscore.to_sym end |
#to_hash ⇒ Object
21 22 23 |
# File 'lib/payu_za/structs/struct_model.rb', line 21 def to_hash vars_to_hash end |
#valid? ⇒ Boolean
9 10 11 |
# File 'lib/payu_za/structs/struct_model.rb', line 9 def valid? validate! rescue false end |
#validate! ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/payu_za/structs/struct_model.rb', line 13 def validate! self.class.fields.each do |name, | if [:required] && send(name).nil? raise StructNotValidError.new(name, 'is required') end end end |