module CIMI::Model::Schema::DSL

The DSL

Requires that the class into which this is included has a add_attributes! method

Public Instance Methods

array(name, opts={}, &block) click to toggle source
# File lib/cimi/models/schema.rb, line 283
def array(name, opts={}, &block)
  add_attributes!([name, opts], Array, &block)
end
collection(name, opts={}) click to toggle source
# File lib/cimi/models/schema.rb, line 295
def collection(name, opts={})
  text :count

  array :operations do
    scalar :rel, :href
  end
end
hash(name) click to toggle source
# File lib/cimi/models/schema.rb, line 291
def hash(name)
  add_attributes!([name, {}], Hash)
end
href(*args) click to toggle source
# File lib/cimi/models/schema.rb, line 269
def href(*args)
  opts = args.extract_opts!
  args.each { |arg| struct(arg, opts) { scalar :href } }
end
scalar(*args) click to toggle source
# File lib/cimi/models/schema.rb, line 279
def scalar(*args)
  add_attributes!(args, Scalar)
end
struct(name, opts={}, &block) click to toggle source
# File lib/cimi/models/schema.rb, line 287
def struct(name, opts={}, &block)
  add_attributes!([name, opts], Struct, &block)
end
text(*args) click to toggle source
# File lib/cimi/models/schema.rb, line 274
def text(*args)
  args.expand_opts!(:text => :nested)
  scalar(*args)
end