Module: ApiClientBulkLoader::Client::BulkLoadHelper
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/api_client_bulk_loader/client/bulk_load_helper.rb
Overview
Included in the client base models
Instance Method Summary collapse
-
#as_json(options = nil) ⇒ Object
we need to override this, as if it is called before we actually hit a bulk-loaded assocation, it will attempt to JSON serialize a proc, which isn’t good.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object (protected)
42 43 44 45 46 47 48 49 50 |
# File 'lib/api_client_bulk_loader/client/bulk_load_helper.rb', line 42 def method_missing(method, *args, &block) if method.to_s =~ /^(.*)=$/ set_attribute($1, args.first) elsif has_attribute?(method) read_attribute(method) else super end end |
Instance Method Details
#as_json(options = nil) ⇒ Object
we need to override this, as if it is called before we actually hit a bulk-loaded assocation, it will attempt to JSON serialize a proc, which isn’t good. To remedy this, we forcefully call each attribute and if it’s a proc, we fire that bulk fetch.
35 36 37 38 |
# File 'lib/api_client_bulk_loader/client/bulk_load_helper.rb', line 35 def as_json(=nil) prepare_attributes_hash super() end |