Class: QboRails
- Inherits:
-
Object
- Object
- QboRails
- Includes:
- ActiveSupport::Rescuable, ErrorHandler
- Defined in:
- lib/qbo_rails.rb,
lib/qbo_rails/version.rb,
lib/qbo_rails/error_handler.rb,
lib/generators/qbo_rails/install/install_generator.rb
Defined Under Namespace
Modules: ErrorHandler, Generators
Constant Summary collapse
- VERSION =
"1.0.2"
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
-
#error ⇒ Object
Returns the value of attribute error.
-
#only_run_once ⇒ Object
Returns the value of attribute only_run_once.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Instance Method Summary collapse
- #create(qb_record) ⇒ Object
- #create_or_update(record, qb_record) ⇒ Object
- #delete(record_or_qbo_id) ⇒ Object
-
#initialize(account, type = nil) ⇒ QboRails
constructor
A new instance of QboRails.
Constructor Details
#initialize(account, type = nil) ⇒ QboRails
Returns a new instance of QboRails.
17 18 19 |
# File 'lib/qbo_rails.rb', line 17 def initialize(account, type = nil) @base = Quickbooks::Base.new(account, type) end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
6 7 8 |
# File 'lib/qbo_rails.rb', line 6 def base @base end |
#error ⇒ Object
Returns the value of attribute error.
5 6 7 |
# File 'lib/qbo_rails.rb', line 5 def error @error end |
#only_run_once ⇒ Object
Returns the value of attribute only_run_once.
5 6 7 |
# File 'lib/qbo_rails.rb', line 5 def only_run_once @only_run_once end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
6 7 8 |
# File 'lib/qbo_rails.rb', line 6 def result @result end |
Instance Method Details
#create(qb_record) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/qbo_rails.rb', line 21 def create(qb_record) with_rescued_exception do @qb_record = qb_record @result = @base.service.create(@qb_record) @result end end |
#create_or_update(record, qb_record) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/qbo_rails.rb', line 29 def create_or_update(record, qb_record) with_rescued_exception do @record = record @qb_record = qb_record if id = @record.send(foreign_key) prepare_update(id, qb_record) @result = @base.service.update(qb_record) else @result = @base.service.create(@qb_record) set_qbo_id end end end |
#delete(record_or_qbo_id) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/qbo_rails.rb', line 43 def delete(record_or_qbo_id) with_rescued_exception do id = record_or_qbo_id.try(foreign_key) || record_or_qbo_id @qb_record = @base.find_by_id(id) @result = @base.service.delete(@qb_record) end end |