Skip to content

Commit

Permalink
created dedicated class for attribute properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Feldhaus committed May 19, 2012
1 parent b74cecd commit fcf81ba
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions lib/occi/core/Attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,24 @@
##############################################################################

##############################################################################
# Description: storing all Attributes for Kinds
# Description: storing a single Attribute
# Author(s): Hayati Bice, Florian Feldhaus, Piotr Kasprzak
##############################################################################

module OCCI
module Core
class Attributes < Hash
class Attributes < Hashie::Mash

def <<(attribute)
store(attribute.name, attribute)
end

def check(attributes)
values.each do |attribute|
raise "Mandatory attribute #{attribute.name} not provided" if attribute.required && !attributes.has_key?(attribute.name)
end
end

def to_s()
string = ""
values.each do
|attribute|
string += attribute.to_s + ' '
def combine
hash = {}
self.each_key do |key|
if self[key].kind_of? Hashie::Mash
self[key].combine.each_pair { |k, v| hash[key + '.' + k] = v }
else
hash[key] = self[key]
end
end
return string.strip()
return hash
end

end
Expand Down

0 comments on commit fcf81ba

Please sign in to comment.