Module: Beefcake::Message::Dsl

Defined in:
lib/beefcake.rb

Instance Method Summary collapse

Instance Method Details

#field(rule, name, type, fn, opts) ⇒ Object



47
48
49
50
# File 'lib/beefcake.rb', line 47

def field(rule, name, type, fn, opts)
  fields[fn] = Field.new(rule, name, type, fn, opts)
  attr_accessor name
end

#fieldsObject



52
53
54
# File 'lib/beefcake.rb', line 52

def fields
  @fields ||= {}
end

#optional(name, type, fn, opts = {}) ⇒ Object



43
44
45
# File 'lib/beefcake.rb', line 43

def optional(name, type, fn, opts={})
  field(:optional, name, type, fn, opts)
end

#repeated(name, type, fn, opts = {}) ⇒ Object



39
40
41
# File 'lib/beefcake.rb', line 39

def repeated(name, type, fn, opts={})
  field(:repeated, name, type, fn, opts)
end

#required(name, type, fn, opts = {}) ⇒ Object



35
36
37
# File 'lib/beefcake.rb', line 35

def required(name, type, fn, opts={})
  field(:required, name, type, fn, opts)
end