Module: Conexa
- Defined in:
- lib/conexa.rb,
lib/conexa/util.rb,
lib/conexa/model.rb,
lib/conexa/errors.rb,
lib/conexa/object.rb,
lib/conexa/request.rb,
lib/conexa/version.rb,
lib/conexa/configuration.rb,
lib/conexa/resources/auth.rb,
lib/conexa/resources/bill.rb,
lib/conexa/resources/plan.rb,
lib/conexa/resources/sale.rb,
lib/conexa/resources/charge.rb,
lib/conexa/resources/person.rb,
lib/conexa/resources/result.rb,
lib/conexa/resources/account.rb,
lib/conexa/resources/address.rb,
lib/conexa/resources/company.rb,
lib/conexa/resources/product.rb,
lib/conexa/resources/contract.rb,
lib/conexa/resources/customer.rb,
lib/conexa/resources/supplier.rb,
lib/conexa/resources/pagination.rb,
lib/conexa/resources/cost_center.rb,
lib/conexa/resources/credit_card.rb,
lib/conexa/resources/legal_person.rb,
lib/conexa/resources/room_booking.rb,
lib/conexa/resources/bill_category.rb,
lib/conexa/resources/payment_method.rb,
lib/conexa/resources/recurring_sale.rb,
lib/conexa/resources/bill_subcategory.rb,
lib/conexa/resources/invoicing_method.rb,
lib/conexa/resources/receiving_method.rb,
lib/conexa/resources/service_category.rb
Defined Under Namespace
Classes: Account, Address, Auth, Bill, BillCategory, BillSubcategory, Charge, Company, ConexaError, ConexaObject, Configuration, ConnectionError, Contract, CostCenter, CreditCard, Customer, Error, InvoicingMethod, LegalPerson, MissingCredentialsError, Model, NotFound, Pagination, ParamError, PaymentMethod, Person, Plan, Product, ReadOnlyError, ReceivingMethod, RecurringSale, Request, RequestError, ResponseError, Result, RoomBooking, Sale, ServiceCategory, Supplier, Util, ValidationError
Constant Summary collapse
- READ_ONLY_KEY =
Key for the block-scoped read-only override. Thread-local so a guarded block in one thread cannot relax or tighten another.
:conexa_read_only- VERSION =
"0.2.0"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .api_endpoint ⇒ Object
- .configure {|configuration| ... } ⇒ Object
-
.read_only(enabled = true) ⇒ Object
Run a block with writes forbidden, then restore the previous state.
-
.read_only? ⇒ Boolean
Is writing currently forbidden?.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
21 22 23 |
# File 'lib/conexa.rb', line 21 def configuration @configuration end |
Class Method Details
.api_endpoint ⇒ Object
29 30 31 |
# File 'lib/conexa.rb', line 29 def self.api_endpoint configuration.api_host + "/index.php/api/v2" end |
.configure {|configuration| ... } ⇒ Object
24 25 26 27 |
# File 'lib/conexa.rb', line 24 def self.configure self.configuration ||= Configuration.new yield(configuration) end |
.read_only(enabled = true) ⇒ Object
Run a block with writes forbidden, then restore the previous state.
Useful for auditing or reporting code that should never mutate a tenant, without having to reconfigure the client globally.
63 64 65 66 67 68 69 |
# File 'lib/conexa.rb', line 63 def self.read_only(enabled = true) previous = Thread.current[READ_ONLY_KEY] Thread.current[READ_ONLY_KEY] = enabled yield ensure Thread.current[READ_ONLY_KEY] = previous end |
.read_only? ⇒ Boolean
Is writing currently forbidden?
True inside a read_only block, or whenever configuration.read_only is set
(which itself defaults from CONEXA_READ_ONLY).
43 44 45 46 47 48 |
# File 'lib/conexa.rb', line 43 def self.read_only? scoped = Thread.current[READ_ONLY_KEY] return scoped unless scoped.nil? !!configuration&.read_only end |