Last active
July 9, 2021 14:41
-
-
Save lumentut/f70e753b75ced06caea91c4b5afbbfc6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DataTypes | |
def initialize | |
@columns = {} | |
end | |
def columns | |
@columns | |
end | |
def col(name, args) | |
@columns[name] = args | |
end | |
end | |
class Test | |
def initialize | |
@queries = {} | |
end | |
def queries | |
@queries | |
end | |
def column_defs(query_name, &block) | |
data_types = DataTypes.new | |
yield data_types | |
queries[query_name] = data_types.columns | |
puts queries | |
end | |
end | |
test = Test.new | |
test.column_defs :test_query do |q| | |
q.col :satu ,type: :string, length: 10 | |
q.col :dua ,type: :integer, length: 5 | |
q.col :tiga ,type: :boolean, default: true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment