Module: CIMI::Model::Schema::DSL
- Included in:
- Resource, CIMI::Model::Schema
- Defined in:
- lib/cimi/models/schema.rb
Overview
The DSL
Requires that the class into which this is included has a add_attributes!
method
Instance Method Summary collapse
- #array(name, opts = {}, &block) ⇒ Object
- #collection(name, opts = {}) ⇒ Object
- #hash(name) ⇒ Object
- #href(*args) ⇒ Object
- #resource_attr(name, opts = {}) ⇒ Object
- #scalar(*args) ⇒ Object
- #struct(name, opts = {}, &block) ⇒ Object
- #text(*args) ⇒ Object
Instance Method Details
#array(name, opts = {}, &block) ⇒ Object
361 362 363 |
# File 'lib/cimi/models/schema.rb', line 361 def array(name, opts={}, &block) add_attributes!([name, opts], Array, &block) end |
#collection(name, opts = {}) ⇒ Object
373 374 375 376 |
# File 'lib/cimi/models/schema.rb', line 373 def collection(name, opts={}) opts[:scope] = self.class add_attributes!([name, opts], Collection) end |
#hash(name) ⇒ Object
369 370 371 |
# File 'lib/cimi/models/schema.rb', line 369 def hash(name) add_attributes!([name, {}], Hash) end |
#href(*args) ⇒ Object
347 348 349 350 |
# File 'lib/cimi/models/schema.rb', line 347 def href(*args) opts = args.extract_opts! args.each { |arg| struct(arg, opts) { scalar :href } } end |
#resource_attr(name, opts = {}) ⇒ Object
338 339 340 341 342 343 344 345 |
# File 'lib/cimi/models/schema.rb', line 338 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 |
#scalar(*args) ⇒ Object
357 358 359 |
# File 'lib/cimi/models/schema.rb', line 357 def scalar(*args) add_attributes!(args, Scalar) end |
#struct(name, opts = {}, &block) ⇒ Object
365 366 367 |
# File 'lib/cimi/models/schema.rb', line 365 def struct(name, opts={}, &block) add_attributes!([name, opts], Struct, &block) end |
#text(*args) ⇒ Object
352 353 354 355 |
# File 'lib/cimi/models/schema.rb', line 352 def text(*args) args.(:text => :nested) scalar(*args) end |