Sha256: ce94fa019b13f62daffc32b27d7b6a57b7eaba37d5d748ad43353a29132b6bd5
Contents?: true
Size: 775 Bytes
Versions: 1
Compression:
Stored size: 775 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 Husky::Repo::Registry.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.2.0 | lib/husky/data_source.rb |