class VersionOne::Meta

Attributes

attributes[R]
name[R]

Public Class Methods

get(asset_type, client=nil) click to toggle source
# File lib/version-one/meta.rb, line 14
def self.get(asset_type, client=nil)
  client ||= VersionOne::Client.new

  xml = client.get('/meta.v1/' + asset_type, cache: {
      key: "VersionOne/meta/#{asset_type}",
      options: {
        expires_in: 60 * 60 * 24,
        race_condition_ttl: 5
      }
  })

  new(xml)
end
new(xml) click to toggle source
# File lib/version-one/meta.rb, line 10
def initialize(xml)
  parse_xml(xml)
end

Public Instance Methods

[](name) click to toggle source
# File lib/version-one/meta.rb, line 28
def [](name)
  @named_attributes[name]
end
inspect() click to toggle source
# File lib/version-one/meta.rb, line 32
def inspect
  '#<Meta:%s>' % [self.name]
end

Private Instance Methods

parse_xml(xml) click to toggle source
# File lib/version-one/meta.rb, line 38
def parse_xml(xml)
  @name = xml.attributes['name']
  @attributes = []
  @named_attributes = {}

  xml.each do |child|
    next unless child.element? && (child.name == 'AttributeDefinition')
    a = AttributeDefinition.new(child)
    next if a.name == 'ID'
    @attributes << a
    @named_attributes[a.name] = a
  end

end