Sha256: 7df84e8d4661fe02e65610a78dffe2c8d4cea3f821a72867daf3cc8808f41beb
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
module Schematic module Generator class Sandbox attr_accessor :ignored_elements, :added_elements def initialize(klass) @klass = klass @ignored_elements ||= [] @added_elements ||= {} end def run(&block) instance_eval &block end def xsd_generator @xsd_generator ||= Schematic::Generator::Xsd.new(@klass) end def to_xsd(options = {}) output = "" builder = Builder::XmlMarkup.new(:target => output, :indent => 2) xsd_generator.options = options xsd_generator.header(builder) xsd_generator.schema(builder) output end def generate_xsd(builder, klass, options) xsd_generator.options = options xsd_generator.generate(builder, klass) end def ignore(*fields) fields.each { |field| ignored_elements << field } end def element(*args) name = args.shift if name.is_a? Hash added_elements[name.keys.first] = name.values.first else added_elements[name] = nil end end def method_missing(method, *args, &block) @klass.send method, *args, &block end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
schematic-0.4.1 | lib/schematic/generator/sandbox.rb |