Class: Libsql::NamedArgBuilder
- Inherits:
-
Object
- Object
- Libsql::NamedArgBuilder
- Defined in:
- lib/libsql.rb
Instance Attribute Summary collapse
-
#kwargs ⇒ Object
readonly
Returns the value of attribute kwargs.
Instance Method Summary collapse
- #build ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(**kwargs) ⇒ NamedArgBuilder
constructor
A new instance of NamedArgBuilder.
- #key ⇒ Object
Constructor Details
#initialize(**kwargs) ⇒ NamedArgBuilder
Returns a new instance of NamedArgBuilder.
102 103 104 |
# File 'lib/libsql.rb', line 102 def initialize(**kwargs) @kwargs = kwargs end |
Instance Attribute Details
#kwargs ⇒ Object (readonly)
Returns the value of attribute kwargs.
100 101 102 |
# File 'lib/libsql.rb', line 100 def kwargs @kwargs end |
Instance Method Details
#build ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/libsql.rb', line 110 def build kwargs.reduce([]) do |acc, (key, value)| type = case value in Integer "integer" in NilClass "null" else "text" end acc << { name: key, value: { type:, value: } } end end |
#empty? ⇒ Boolean
106 |
# File 'lib/libsql.rb', line 106 def empty? = @kwargs.empty? |
#key ⇒ Object
108 |
# File 'lib/libsql.rb', line 108 def key = :named_args |