Sha256: 73c093c035b832eae7da43fad617ace5f1a2d6c25f6de867ba00c66f3c170ef4
Contents?: true
Size: 948 Bytes
Versions: 14
Compression:
Stored size: 948 Bytes
Contents
module KB module Queryable class KBClientNotSetException < StandardError; end extend ActiveSupport::Concern included do class_attribute :resolver_factory end module ClassMethods def kb_client if resolver_factory.blank? raise KBClientNotSetException, "You probably forgot to call `kb_api ...` on the class #{name}" end @kb_client ||= ClientResolver.public_send(resolver_factory) end def from_api(attributes) new(attributes_from_response(attributes), &:persist!).tap(&:clear_changes_information) end private def kb_api(resolver_factory) self.resolver_factory = resolver_factory end # @abstract Subclass is expected to implement #attributes_from_response # @!method attributes_from_response # Filter and process the response to return the relevant attributes for entity initialization end end end
Version data entries
14 entries across 14 versions & 1 rubygems