Class: Sequel::Schema::DbColumn::OptionBuilder
- Inherits:
-
Object
- Object
- Sequel::Schema::DbColumn::OptionBuilder
- Defined in:
- lib/sequel/schema/db_column.rb
Overview
Formats column options in a Sequel migration
Instance Method Summary collapse
-
#initialize ⇒ OptionBuilder
constructor
A new instance of OptionBuilder.
-
#render ⇒ Object
Renders the column option hash in a pretty format.
-
#set(name, value) ⇒ Object
Sets column option name to a value.
Constructor Details
#initialize ⇒ OptionBuilder
Returns a new instance of OptionBuilder.
168 169 170 |
# File 'lib/sequel/schema/db_column.rb', line 168 def initialize @opts = [] end |
Instance Method Details
#render ⇒ Object
Renders the column option hash in a pretty format.
184 185 186 |
# File 'lib/sequel/schema/db_column.rb', line 184 def render @opts.join(", ") unless @opts.empty? end |
#set(name, value) ⇒ Object
Sets column option name to a value.
173 174 175 176 177 178 179 180 181 |
# File 'lib/sequel/schema/db_column.rb', line 173 def set(name, value) output_value = if value.kind_of?(BigDecimal) "BigDecimal.new('#{value.to_f.to_s}')" else value.inspect end @opts << "#{name.inspect} => #{output_value}" end |