Method: Representable::XML::Namespace::DSL#property

Defined in:
lib/representable/xml/namespace.rb

#property(name, options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/representable/xml/namespace.rb', line 29

def property(name, options={})
  uri = representable_attrs.options[:local_namespace] # per default, a property belongs to the local namespace.
  options[:namespace] ||= uri # don't override if already set.

  # a nested representer is automatically assigned "its" local namespace. It's like saying
  #   property :author, namespace: "http://ns/author" do ... end

  super.tap do |dfn|
    if dfn.typed? # FIXME: ouch, this should be doable with property's API to hook into the creation process.
      dfn.merge!( namespace: dfn.representer_module.representable_attrs.options[:local_namespace] )

      update_namespace_defs!(namespace_defs)
    end
  end
end