Sha256: 5127755a8c90be642e21c6495f81da626d157146cd591848c0909c64a18c4766
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true module Hws module Stores # :nodoc: def self.create_store(input) allowed_input = input.with_indifferent_access.slice('name', 'description', 'data', 'schema', 'tags') if allowed_input.key?('data') if allowed_input['data'].is_a?(Numeric) allowed_input['value'] == allowed_input.delete('data') else allowed_input['data'] = allowed_input['data'].with_indifferent_access end end store = Hws::Stores::Models::Store.create(allowed_input) store.try(:id) end def self.update_store(store_id, data) data = data.with_indifferent_access store = ::Hws::Stores::Models::Store.find(store_id) return false if store.nil? if data.is_a?(Numeric) store.update!(value: data, data: nil) else store.update!(value: nil, data: data) end end def self.delete_store(store_id) store = ::Hws::Stores::Models::Store.find(store_id) return false if store.nil? store.delete.present? end module Models # :nodoc: end end end require 'hws-stores/models/store' require 'hws-stores/models/owner'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hws-stores-0.1.0 | lib/hws-stores.rb |