Class: ActionWebService::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/action_web_service/simple.rb

Overview

To send simple types across the wire, derive from ActionWebService::Simple, and use base to declare the base type for it restriction and, use restriction to declare valid W3C restriction element for SimpleType.

ActionWebService::Simple should be used when you want to declare valid custom simple type to be used inside expects, returns and structured types

There plenty documentation available at W3C Archives www.w3.org/TR/xmlschema-2/

Example

class Gender < ActionWebService::Simple
  base :string
  restriction :enumeration, "male|female"
end

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Simple

Returns a new instance of Simple.



24
25
26
# File 'lib/action_web_service/simple.rb', line 24

def initialize(value)
  @value = value
end

Class Method Details

.base(type) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/action_web_service/simple.rb', line 29

def base(type)
  type = type.to_s.camelize(:lower)
  write_inheritable_attribute("xml_base", type)
  class_eval <<-END
    def xml_base; "#{type}"; end
  END
end

.restriction(type, value) ⇒ Object



41
42
43
44
# File 'lib/action_web_service/simple.rb', line 41

def restriction(type, value)
  type = type.to_s.camelize(:lower)
  write_inheritable_hash("simple_restrictions", type => value)
end

.restriction_baseObject



37
38
39
# File 'lib/action_web_service/simple.rb', line 37

def restriction_base
  read_inheritable_attribute("xml_base") || ""
end

.restrictionsObject



46
47
48
# File 'lib/action_web_service/simple.rb', line 46

def restrictions
  read_inheritable_attribute("simple_restrictions") || {}
end