class Pump::Dsl

Public Class Methods

new(&blk) click to toggle source
# File lib/pump/dsl.rb, line 3
def initialize(&blk)
  raise ArgumentError unless block_given?
  instance_eval(&blk)
end

Public Instance Methods

config() click to toggle source
# File lib/pump/dsl.rb, line 8
def config
  @config ||= []
end

Private Instance Methods

array(name, options={}, &blk) click to toggle source
# File lib/pump/dsl.rb, line 52
def array(name, options={}, &blk)
  options[:array] = self.class.new(&blk).config
  tag(name, options)
end
boolean(name, options={}) click to toggle source
# File lib/pump/dsl.rb, line 32
def boolean(name, options={})
  with_type('boolean', name, options)
end
date(name, options={}) click to toggle source
# File lib/pump/dsl.rb, line 36
def date(name, options={})
  with_type('date', name, options)
end
datetime(name, options={}) click to toggle source
# File lib/pump/dsl.rb, line 40
def datetime(name, options={})
  options[:typecast] = :xmlschema unless options.has_key?(:typecast)
  with_type('datetime', name, options)
end
Also aliased as: time
float(name, options={}) click to toggle source
# File lib/pump/dsl.rb, line 28
def float(name, options={})
  with_type('float', name, options)
end
integer(name, options={}) click to toggle source
# File lib/pump/dsl.rb, line 24
def integer(name, options={})
  with_type('integer', name, options)
end
string(name, options={}, &blk)
Alias for: tag
tag(name, options={}, &blk) click to toggle source
# File lib/pump/dsl.rb, line 14
def tag(name, options={}, &blk)
  method = if block_given?
    self.class.new(&blk).config
  else
    options.delete(:from) || (name.to_s =~ /-/ ? name.to_s.gsub('-', '_').to_sym : name)
  end
  config << ({ name => method }).merge(options)
end
Also aliased as: string
time(name, options={})
Alias for: datetime
with_type(type, name, options) click to toggle source
# File lib/pump/dsl.rb, line 46
def with_type(type, name, options)
  (options[:attributes] ||= {}).merge!({:type => type})
  options[:xmlsafe] = true unless options.has_key?(:xmlsafe)
  tag(name, options)
end