Class: ActiveRecordish::Base
- Inherits:
-
Object
- Object
- ActiveRecordish::Base
- Defined in:
- lib/active_recordish.rb
Class Method Summary collapse
- .all ⇒ Object
-
.where(options = {}) ⇒ Object
#where(name: “aaa”, old: 13).
Instance Method Summary collapse
Class Method Details
.all ⇒ Object
6 7 8 |
# File 'lib/active_recordish.rb', line 6 def all @@active_recordish_instances ||= [] end |
.where(options = {}) ⇒ Object
#where(name: “aaa”, old: 13)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/active_recordish.rb', line 27 def self.where(={}) array = [] self.all.each do |instance| ans = .all? do |_array| at_key = ("@" + _array.first.to_s).to_sym if instance.instance_variables.include?(at_key) at_value = instance.instance_variable_get(at_key.to_s) at_value.to_s == _array.last.to_s else false end end array << instance if ans end array end |
Instance Method Details
#destroy ⇒ Object
22 23 24 |
# File 'lib/active_recordish.rb', line 22 def destroy @@active_recordish_instances.destroy(self) end |
#save ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/active_recordish.rb', line 12 def save @@active_recordish_instances ||= [] if @@active_recordish_instances.none?{|ari| ari.object_id == self.object_id} @@active_recordish_instances << self true else false end end |