Sha256: bb1a5db082dadd5ab8adcf2e30e957df50b256a13a22f296caf7490cd6f5cdee
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
= Schematic * http://github.com/casecommons/schematic/ == DESCRIPTION Automatic XSD generation for your ActiveRecord models == INSTALL Add schematic to your Gemfile gem 'schematic' Then run: $ bundle install == USAGE class Post < ActiveRecord::Base end Post.to_xsd => (a bunch of xml) You can include additional elements by defining a ".xsd_methods" on your class: class Post < ActiveRecord::Base def self.xsd_methods {:title => nil, :author => [:name, :email, :url]} end end You can exclude elements by defining a ".xsd_ignore_methods" on your class: class Post < ActiveRecord::Base def self.xsd_ignore_methods [:created_at, :updated_at] end end You can define your own custom restrictions by inheriting from the Restrictions Base class: class MyCustomRestriction < Schematic::Generator::Restrictions::Base def generate(builder) for_validator ActiveModel::BlockValidator do |validator| builder.xs(:enumeration, "value" => "foo") builder.xs(:enumeration, "value" => "bar") end end end You can have a custom pattern restriction from a custom validater: class MyValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) ... end def xsd_pattern_restrictions [/foo/, /bar/] end end You can have a custom enumeration restriction from a custom validater: class MyValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) ... end def xsd_field_enumeration_restrictions ["foo", "bar"] end end == REQUIREMENTS * ActiveRecord 3.x == LICENSE MIT
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
schematic-0.3.7 | README.rdoc |