Module: Enterprisifier::Marshalling::Reification

Included in:
XSD::Types::Boolean, XSD::Types::Date, XSD::Types::DateTime, XSD::Types::Decimal, XSD::Types::String, XSD::Types::Time
Defined in:
lib/enterprisifier/marshalling/reification.rb

Instance Method Summary collapse

Instance Method Details

#reify(reified) ⇒ Object

TODO:
  • this is ugly.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/enterprisifier/marshalling/reification.rb', line 7

def reify(reified)
  here = self
  reified.instance_eval do
    define_method(:value=) do |ruby_val|
      (@value ||= here.new).value = ruby_val
    end

    define_method(:value) do
      @value ? @value.ruby_value : nil
    end

    define_method(:value_from_string) do |str_val|
      @value ||= here.from_string(str_val)
    end

    define_method(:value_to_string) do
      @value ? @value.to_xml_string : nil
    end
  end
end