Sha256: cb8f13e2a37dd81bb96ff07f81fe2f4488ce924a76fb93fae0234456b4acb0cd
Contents?: true
Size: 764 Bytes
Versions: 1
Compression:
Stored size: 764 Bytes
Contents
module Husky module DataSource class InMemory class << self def has_many(association) define_method association do singular_association = association.to_s[0..-2].to_sym klass_id = "#{self.class.name.split('::')[1].downcase}_id".to_sym Repository.for(singular_association).all.select { |k,v| v.send(klass_id) == self.id } end end end attr_reader :attributes attr_accessor :id def initialize(attributes) @attributes = attributes end def update_attributes(attrs) @attributes.each do |key, value| if attrs.key?(key) @attributes[key] = attrs[key] end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
husky-0.1.9 | lib/husky/data_source.rb |