Class: Strike::Table

Inherits:
Object
  • Object
show all
Defined in:
lib/strike/table.rb

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Table

Returns a new instance of Table.

Yields:

  • (_self)

Yield Parameters:

  • _self (Strike::Table)

    the object that the method was called on



5
6
7
8
# File 'lib/strike/table.rb', line 5

def initialize(&block)
  @definition ||= {}
  yield self if block_given?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



10
11
12
13
14
# File 'lib/strike/table.rb', line 10

def method_missing(method, *args, &block)
  @definition[method] = block_given? ?  yield(self) : args.first

  true
end

Instance Method Details

#callObject



16
17
18
# File 'lib/strike/table.rb', line 16

def call
  to_hash
end

#to_hashObject



20
21
22
# File 'lib/strike/table.rb', line 20

def to_hash
  @definition
end