Class: WADL::FaultFormat

Inherits:
RepresentationFormat show all
Defined in:
lib/wadl/fault_format.rb

Constant Summary

Constant Summary

Constants inherited from RepresentationFormat

RepresentationFormat::FORM_TYPES

Constants inherited from CheapSchema

CheapSchema::ATTRIBUTES

Instance Attribute Summary (collapse)

Attributes inherited from CheapSchema

#attributes, #href, #index_key, #parent

Class Method Summary (collapse)

Methods inherited from RepresentationFormat

#%, #is_form_representation?

Methods inherited from HasDocs

#define_singleton

Methods inherited from CheapSchema

as_collection, as_member, contents_are_mixed_data, #dereference, #dereference_with_context, dereferencing_attr_accessor, dereferencing_instance_accessor, #each_attribute, #each_collection, #each_member, has_attributes, has_many, has_one, has_required, in_document, inherit, inherited, init, #initialize, #matches?, may_be_reference, may_be_reference?, #paths, #to_s

Constructor Details

This class inherits a constructor from WADL::CheapSchema

Instance Attribute Details

- (Object) subclass



40
41
42
# File 'lib/wadl/fault_format.rb', line 40

def subclass
  attributes['href'] ? dereference.subclass : @subclass
end

Class Method Details

+ (Object) from_element(*args)

Define a custom subclass for this fault, so that the programmer can rescue this particular fault.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/wadl/fault_format.rb', line 46

def self.from_element(*args)
  me = super

  me.subclass = if name = me.attributes['id']
    begin
      Faults.const_defined?(name) ?
        Faults.const_get(name) :
        Faults.const_set(name, Class.new(Fault))
    rescue NameError
      # This fault format's ID can't be a class name. Use the
      # generic subclass of Fault.
    end
  end || Fault unless me.attributes['href']

  me
end