The DSL
Requires that the class into which this is included has a
add_attributes!
method
# File lib/cimi/models/schema.rb, line 448 def array(name, opts={}, &block) add_attributes!([name, opts], Array, &block) end
# File lib/cimi/models/schema.rb, line 468 def collection(name, opts={}) opts[:scope] = self.class add_attributes!([name, opts], Collection) end
# File lib/cimi/models/schema.rb, line 464 def hash(name) add_attributes!([name, {}], Hash) end
# File lib/cimi/models/schema.rb, line 434 def href(*args) opts = args.extract_opts! args.each { |arg| struct(arg, opts) { scalar :href, :required => opts[:required] } } end
# File lib/cimi/models/schema.rb, line 456 def ref(name, opts={}) unless opts[:class] s = name.to_s.camelize.gsub(%rConfig$/, "Configuration") opts[:class] = CIMI::Model::const_get(s) end add_attributes!([name, opts], Ref) end
# File lib/cimi/models/schema.rb, line 425 def resource_attr(name, opts={}) CIMI::Model::ResourceMetadata.add_resource_attribute!(self, name, opts) if opts[:type] send(opts[:type], name) else text name end end
# File lib/cimi/models/schema.rb, line 444 def scalar(*args) add_attributes!(args, Scalar) end
# File lib/cimi/models/schema.rb, line 452 def struct(name, opts={}, &block) add_attributes!([name, opts], Struct, &block) end
# File lib/cimi/models/schema.rb, line 439 def text(*args) args.expand_opts!(:text => :nested) scalar(*args) end