Class: MetabaseQuerySync::MetabaseApi::Model

Inherits:
Dry::Struct
  • Object
show all
Defined in:
lib/metabase_query_sync/metabase_api/model.rb

Class Method Summary collapse

Class Method Details

.has(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/metabase_query_sync/metabase_api/model.rb', line 5

def self.has(*args)
  args.each do |sym|
    case sym
    when :id
      attribute :id, MetabaseQuerySync::Types::Strict::Integer.optional.default(nil)
    when :archived
      attribute :archived, MetabaseQuerySync::Types::Strict::Bool.default(false)
    when :name
      attribute :name, MetabaseQuerySync::Types::Strict::String
    when :description
      attribute :description, MetabaseQuerySync::Types::Strict::String.optional.default(nil)
    when :collection_id
      attribute :collection_id, MetabaseQuerySync::Types::Strict::Integer.optional.default(nil)
    else
      raise "Unexpected field for model (#{sym})"
    end
  end
end