Method: Record.define

Defined in:
lib/record/base.rb

.define(super_class = Base, &block) ⇒ Object

alternative class (record) builder



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/record/base.rb', line 151

def self.define( super_class=Base, &block )   ## check: rename super_class to base - why? why not?

  builder = Builder.new( super_class )
  if block.arity == 1
    block.call( builder )
    ## e.g. allows "yield" dsl style e.g.

    ##  Record.define do |rec|

    ##     rec.string :team1

    ##     rec.string :team2

    ##  end

    ##

  else
    builder.instance_eval( &block )
    ## e.g. shorter "instance eval" dsl style e.g.

    ##  Record.define do

    ##     string :team1

    ##     string :team2

    ##  end

  end
  builder.to_record
end