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.



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

def initialize(value)
  @value = value
end

Class Method Details

.base(type) ⇒ Object



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

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



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

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

.restriction_baseObject



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

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

.restrictionsObject



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

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