Module: HealthGraph::Model::ClassMethods

Defined in:
lib/health_graph/model.rb

Instance Method Summary collapse

Instance Method Details

#from_hash(hash) {|instance| ... } ⇒ Object

Yields:

  • (instance)


12
13
14
15
16
# File 'lib/health_graph/model.rb', line 12

def from_hash(hash) 
  instance = new(hash)
  yield instance if block_given?
  instance
end

#hash_attr_accessor(*symbols) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/health_graph/model.rb', line 18

def hash_attr_accessor(*symbols)
  attr_writer(*symbols)
  symbols.each do |symbol|
    define_method(symbol) do            
      instance_variable_get("@#{symbol}")
    end
  end
end