Module: Dddr::Sdbm

Defined in:
lib/dddr/sdbm.rb

Defined Under Namespace

Modules: ClassMethods Classes: RepositoryBase

Instance Method Summary collapse

Instance Method Details

#from_hash(uid, data_hash) ⇒ Object



170
171
172
173
174
175
176
177
178
# File 'lib/dddr/sdbm.rb', line 170

def from_hash(uid, data_hash)
  self.uid = uid
  data_hash&.each do |attribute, value|
    attribute = attribute.to_sym
    if respond_to?(:"#{attribute}=")
      send(:"#{attribute}=", value)
    end
  end
end

#to_hashObject



161
162
163
164
165
166
167
168
# File 'lib/dddr/sdbm.rb', line 161

def to_hash
  result = {}
  instance_variables.each do |var_name|
    attribute_name = var_name.to_s[1..].to_sym
    result[attribute_name] = instance_variable_get(var_name)
  end
  result
end