Module: XDR::DSL::Struct

Included in:
Struct
Defined in:
lib/xdr/dsl/struct.rb

Instance Method Summary collapse

Instance Method Details

#attribute(name, type) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/xdr/dsl/struct.rb', line 2

def attribute(name, type)

  unless type.is_a?(XDR::Concerns::ConvertsToXDR)
    raise ArgumentError, "#{type} does not convert to xdr" 
  end

  self.fields = self.fields.merge(name => type)

  attr_accessor name
  define_attribute_methods name
end