Class: ActiveApi::Schema
- Inherits:
-
Object
- Object
- ActiveApi::Schema
- Defined in:
- lib/active_api/schema.rb
Instance Attribute Summary collapse
-
#definition_class ⇒ Object
readonly
Returns the value of attribute definition_class.
-
#definitions ⇒ Object
readonly
Returns the value of attribute definitions.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #build_xml(objects, options) ⇒ Object
- #define(name, options = {}) {|definition| ... } ⇒ Object
-
#initialize(version, options = {}) ⇒ Schema
constructor
A new instance of Schema.
Constructor Details
#initialize(version, options = {}) ⇒ Schema
Returns a new instance of Schema.
21 22 23 24 25 |
# File 'lib/active_api/schema.rb', line 21 def initialize(version, = {}) @version = version @definitions = [] @definition_class = [:definition_class] end |
Instance Attribute Details
#definition_class ⇒ Object (readonly)
Returns the value of attribute definition_class.
20 21 22 |
# File 'lib/active_api/schema.rb', line 20 def definition_class @definition_class end |
#definitions ⇒ Object (readonly)
Returns the value of attribute definitions.
20 21 22 |
# File 'lib/active_api/schema.rb', line 20 def definitions @definitions end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
20 21 22 |
# File 'lib/active_api/schema.rb', line 20 def version @version end |
Class Method Details
.find(version) ⇒ Object
15 16 17 |
# File 'lib/active_api/schema.rb', line 15 def find(version) versions.detect { |schema| schema.version == version } end |
.version(version, options = {}) {|schema| ... } ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/active_api/schema.rb', line 7 def version(version, = {}) [:definition_class] ||= Definition schema = Schema.new version, yield schema write_inheritable_array :versions, [schema] schema end |
Instance Method Details
#build_xml(objects, options) ⇒ Object
34 35 36 |
# File 'lib/active_api/schema.rb', line 34 def build_xml(objects, ) Collection.new(objects, .merge(:schema => self)).build_xml end |
#define(name, options = {}) {|definition| ... } ⇒ Object
27 28 29 30 31 32 |
# File 'lib/active_api/schema.rb', line 27 def define(name, = {}) [:definition_name] = name definition = definition_class.to_s.constantize.new yield definition if block_given? definitions << definition end |