Sha256: 6a21773fc2f4633ba80fa1cd3124187747169b7f8486daf80d9e257786db95b1
Contents?: true
Size: 866 Bytes
Versions: 12
Compression:
Stored size: 866 Bytes
Contents
module KB class Breed < BaseModel include Listable DEFAULT_LOCALE = ENV.fetch('KB_BREEDS_DEFAULT_LOCALE', 'es-es') kb_api :breed def self.all(filters = {}) filters[:locale] ||= DEFAULT_LOCALE super(filters) end def self.dogs(filters = {}) filters[:species] = 'dog' all(filters) end def self.cats(filters = {}) filters[:species] = 'cat' all(filters) end def self.attributes_from_response(response) response.transform_keys(&:underscore).transform_keys(&:to_sym).slice(*FIELDS) end private_class_method :attributes_from_response STRING_FIELDS = %i[key locale name species weight_group external_id].freeze FIELDS = [*STRING_FIELDS].freeze define_attribute_methods(*FIELDS) STRING_FIELDS.each do |field| attribute field, :string end end end
Version data entries
12 entries across 12 versions & 1 rubygems