Module: KB::Queryable::ClassMethods

Defined in:
lib/kb/models/concerns/queryable.rb

Instance Method Summary collapse

Instance Method Details

#from_api(attributes) ⇒ Object



19
20
21
# File 'lib/kb/models/concerns/queryable.rb', line 19

def from_api(attributes)
  new(attributes_from_response(attributes), &:persist!).tap(&:clear_changes_information)
end

#kb_clientObject



11
12
13
14
15
16
17
# File 'lib/kb/models/concerns/queryable.rb', line 11

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