Class: CIMI::Model::Schema::Array
  
  
  
  Instance Attribute Summary collapse
  
  
  
  Attributes inherited from Attribute
  #json_name, #name, #xml_name
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  Methods inherited from Attribute
  #convert
  Constructor Details
  
    
  
  
    #initialize(name, opts = {}, &block)  ⇒ Array 
  
  
  
  
    
For an array :funThings, we collect all <funThing/> elements (XmlSimple actually does the collecting)
   
 
  
  
    
      
162
163
164
165
166
167
168 
     | 
    
      # File 'lib/cimi/models/schema.rb', line 162
def initialize(name, opts = {}, &block)
  unless opts[:xml_name]
    opts[:xml_name] = name.to_s.singularize.camelize.uncapitalize
  end
  super(name, opts)
  @struct = Struct.new(name, opts, &block)
end
     | 
  
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #struct  ⇒ Object 
  
  
  
  
    
Returns the value of attribute struct.
   
 
  
  
    
      
158
159
160 
     | 
    
      # File 'lib/cimi/models/schema.rb', line 158
def struct
  @struct
end 
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #from_json(json, model)  ⇒ Object 
  
  
  
  
    
      
174
175
176 
     | 
    
      # File 'lib/cimi/models/schema.rb', line 174
def from_json(json, model)
  model[name] = (json[json_name] || []).map { |elt| @struct.convert_from_json(elt) }
end
     | 
  
 
    
      
  
  
    #from_xml(xml, model)  ⇒ Object 
  
  
  
  
    
      
170
171
172 
     | 
    
      # File 'lib/cimi/models/schema.rb', line 170
def from_xml(xml, model)
  model[name] = (xml[xml_name] || []).map { |elt| @struct.convert_from_xml(elt) }
end
     | 
  
 
    
      
  
  
    #to_json(model, json)  ⇒ Object 
  
  
  
  
    
      
183
184
185
186 
     | 
    
      # File 'lib/cimi/models/schema.rb', line 183
def to_json(model, json)
  ary = (model[name] || []).map { |elt| @struct.convert_to_json(elt) }
  json[json_name] = ary unless ary.empty?
end
     | 
  
 
    
      
  
  
    #to_xml(model, xml)  ⇒ Object 
  
  
  
  
    
      
178
179
180
181 
     | 
    
      # File 'lib/cimi/models/schema.rb', line 178
def to_xml(model, xml)
  ary = (model[name] || []).map { |elt| @struct.convert_to_xml(elt) }
  xml[xml_name] = ary unless ary.empty?
end
     |