Class: TableStructure::Schema::Table::ContextBuilder

Inherits:
Module
  • Object
show all
Defined in:
lib/table_structure/schema/table/context_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, callable) ⇒ ContextBuilder

Returns a new instance of ContextBuilder.



7
8
9
10
11
12
13
14
15
# File 'lib/table_structure/schema/table/context_builder.rb', line 7

def initialize(name, callable)
  @available = !callable.nil?

  return unless @available

  define_method(name) do |context: nil|
    super(context: callable.call(context))
  end
end

Instance Method Details

#available?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/table_structure/schema/table/context_builder.rb', line 17

def available?
  @available
end