Module: Beefcake::Message::Dsl

Defined in:
lib/beefcake.rb

Instance Method Summary collapse

Instance Method Details

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


68
69
70
71
72
73
74
# File 'lib/beefcake.rb', line 68

def field(rule, name, type, fn, opts)
  if fields.include?(fn)
    raise DuplicateFieldNumber.new(fn, name)
  end
  fields[fn] = Field.new(rule, name, type, fn, opts)
  attr_accessor name
end

#fieldsObject


76
77
78
# File 'lib/beefcake.rb', line 76

def fields
  @fields ||= {}
end

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


64
65
66
# File 'lib/beefcake.rb', line 64

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

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


60
61
62
# File 'lib/beefcake.rb', line 60

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

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


56
57
58
# File 'lib/beefcake.rb', line 56

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