Module: XsdModel::Elements::AttributeMethods

Included in:
BaseElement, ComplexType, Extension, Import, Include, Schema
Defined in:
lib/xsd_model/elements/attribute_methods.rb

Instance Method Summary collapse

Instance Method Details

#attribute_method(*attr_names) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/xsd_model/elements/attribute_methods.rb', line 8

def attribute_method(*attr_names)
  attr_names.each do |attr_name|
    define_method attr_name.underscore do
      attributes[attr_name.to_s]
    end

    define_method "has_#{attr_name.underscore}?" do
      !attributes[attr_name.to_s].nil?
    end

    define_method "no_#{attr_name.underscore}?" do
      attributes[attr_name.to_s].nil?
    end
  end
end