# File lib/cimi/models/base.rb, line 126 def initialize(values = {}) super(values) retrieve_entity end
# File lib/cimi/models/base.rb, line 131 def []=(a, v) v = super retrieve_entity if a == :id v end
Destroy the database attributes for this model
# File lib/cimi/models/base.rb, line 150 def destroy @entity.destroy self end
FIXME: Kludge around the fact that we do not have proper *Create objects that deserialize properties by themselves
# File lib/cimi/models/base.rb, line 157 def extract_properties!(data) h = {} if data['property'] # Data came from XML h = data['property'].inject({}) do |r,v| r[v['key']] = v['content'] r end elsif data['properties'] h = data['properties'] end property ||= {} property.merge!(h) end
# File lib/cimi/models/base.rb, line 172 def ref_id(ref_url) ref_url.split('/').last if ref_url end
Save the common attributes name, description, and properties to the database
# File lib/cimi/models/base.rb, line 139 def save if @entity @entity.name = name @entity.description = description @entity.properties = property @entity.save end self end