Class: FidorApi::Model::Base
- Inherits:
-
Object
- Object
- FidorApi::Model::Base
- Defined in:
- lib/fidor_api/model/base.rb
Direct Known Subclasses
Account, Card, ConfirmableAction, Customer, Message, Message::Attachment, Message::Content, Preauth, Transaction, Transfer::Classic::Base, Transfer::Generic, User
Instance Attribute Summary collapse
-
#confirmable_action_id ⇒ Object
Returns the value of attribute confirmable_action_id.
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
-
#parse_errors(body) ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Attribute Details
#confirmable_action_id ⇒ Object
Returns the value of attribute confirmable_action_id.
22 23 24 |
# File 'lib/fidor_api/model/base.rb', line 22 def confirmable_action_id @confirmable_action_id end |
Class Method Details
.inherited(klass) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fidor_api/model/base.rb', line 5 def inherited(klass) klass.include ActiveModel::Model klass.include Helpers::ActionViewSupport klass.extend ModelAttribute klass.extend Helpers::AttributeDecimalMethods klass.define_method :initialize do |attributes = {}| set_attributes(attributes) end end |
.resource_name ⇒ Object
17 18 19 |
# File 'lib/fidor_api/model/base.rb', line 17 def resource_name name.sub('FidorApi::Model::', '') end |
Instance Method Details
#as_json ⇒ Object
24 25 26 |
# File 'lib/fidor_api/model/base.rb', line 24 def as_json attributes.compact end |
#parse_errors(body) ⇒ Object
rubocop:disable Metrics/AbcSize
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fidor_api/model/base.rb', line 28 def parse_errors(body) # rubocop:disable Metrics/AbcSize Array(body['errors']).each do |hash| field = hash.delete('field').to_sym key = hash.delete('key') next unless respond_to?(field) || field == :base if key errors.add(field, key.to_sym, hash.symbolize_keys) else errors.add(field, hash.delete('message'), hash.symbolize_keys) end end end |