Module: Rews::Restriction::Xml
- Defined in:
- lib/rews/restriction.rb
Constant Summary collapse
- COMPARISON_OPS =
{ :< => :IsLessThan, :<= => :IsLessThanOrEqualTo, :== => :IsEqualTo, :>= => :IsGreaterThanOrEqualTo, :> => :IsGreaterThan, :"!=" => :IsNotEqualTo}
- LOGICAL_OPS =
{ :and => :And, :or => :Or, :not => :Not }
Class Method Summary collapse
- .write_comparison(xml, expr) ⇒ Object
- .write_constant(xml, expr) ⇒ Object
- .write_expr(xml, expr) ⇒ Object
- .write_field_uri(xml, expr) ⇒ Object
- .write_field_uri_or_constant(xml, expr) ⇒ Object
- .write_logical(xml, expr) ⇒ Object
- .write_restriction(expr) ⇒ Object
Class Method Details
.write_comparison(xml, expr) ⇒ Object
55 56 57 58 59 60 |
# File 'lib/rews/restriction.rb', line 55 def write_comparison(xml, expr) xml.t COMPARISON_OPS[expr[0]] do write_field_uri(xml, expr[1]) write_field_uri_or_constant(xml, expr[2]) end end |
.write_constant(xml, expr) ⇒ Object
76 77 78 |
# File 'lib/rews/restriction.rb', line 76 def write_constant(xml, expr) xml.t :Constant, :Value=>expr end |
.write_expr(xml, expr) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rews/restriction.rb', line 36 def write_expr(xml, expr) case expr[0] when :<, :<=, :==, :>=, :>, :"!=" then write_comparison(xml, expr) when :and, :or, :not then write_logical(xml, expr) else raise "unknown operator: #{expr[0]}" end end |
.write_field_uri(xml, expr) ⇒ Object
72 73 74 |
# File 'lib/rews/restriction.rb', line 72 def write_field_uri(xml, expr) xml.t :FieldURI, :FieldURI=>expr end |
.write_field_uri_or_constant(xml, expr) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/rews/restriction.rb', line 62 def write_field_uri_or_constant(xml, expr) xml.t :FieldURIOrConstant do if expr.is_a?(Array) && expr[0] == :field_uri write_field_uri(xml, expr[1]) else write_constant(xml, expr) end end end |
.write_logical(xml, expr) ⇒ Object
85 86 87 88 89 90 91 |
# File 'lib/rews/restriction.rb', line 85 def write_logical(xml, expr) xml.t LOGICAL_OPS[expr[0]] do expr[1..-1].each do |clause| Xml::write_expr(xml, clause) end end end |
.write_restriction(expr) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/rews/restriction.rb', line 28 def write_restriction(expr) xml = Builder::XmlMarkup.new xml.wsdl :Restriction do write_expr(xml, expr) end xml.target! end |