Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: csun-student-affairs/supermodel
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: ReaxDev/supermodel
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.

Commits on Feb 11, 2011

  1. Encapsulate UniquenessValidator in SuperModel namespace instead of di…

    …rectly monkeypatching ActiveModel.
    
    With the monkeypatch, if SuperModel was used alongside ActiveRecord, Mongoid or any other library that implemented its own UniquenessValidator, conflicts would occur.
    Mani Tadayon authored and maccman committed Feb 11, 2011
    Copy the full SHA
    c2bab16 View commit details

Commits on Jun 7, 2011

  1. Copy the full SHA
    42c9ee1 View commit details
  2. fixing dependecy issue

    ncavig committed Jun 7, 2011
    Copy the full SHA
    0673d1c View commit details
  3. Merge pull request maccman#9 from ncavig/master

    class_inheritable_attribute deprecated in rails 3.1 beta
    maccman committed Jun 7, 2011
    Copy the full SHA
    e68c00c View commit details

Commits on Jun 9, 2011

  1. attempt to fix for rails 3.1

    ncavig committed Jun 9, 2011
    Copy the full SHA
    8c3506d View commit details
  2. Copy the full SHA
    d8beb6d View commit details
  3. primary key

    ncavig committed Jun 9, 2011
    Copy the full SHA
    d44ac5a View commit details
  4. Merge pull request maccman#10 from ncavig/master

    Latest Rails 3.1 rc1 removes some classes
    maccman committed Jun 9, 2011
    Copy the full SHA
    093c2b5 View commit details

Commits on Aug 26, 2011

  1. no dups

    maccman committed Aug 26, 2011
    Copy the full SHA
    826ed6d View commit details
  2. remove serialize_options

    maccman committed Aug 26, 2011
    Copy the full SHA
    f41eaae View commit details
  3. do not dup known_attributes

    maccman committed Aug 26, 2011
    Copy the full SHA
    fdad058 View commit details

Commits on Nov 22, 2011

  1. Fixed small typo in comment in base.rb

    Matt Bridges committed Nov 22, 2011
    Copy the full SHA
    2283a78 View commit details
  2. Merge pull request maccman#13 from mattdbridges/patch-1

    Fixed small typo in comment in base.rb
    maccman committed Nov 22, 2011
    Copy the full SHA
    d5c06b8 View commit details

Commits on Oct 29, 2012

  1. Copy the full SHA
    9e35a02 View commit details

Commits on Apr 20, 2013

  1. Added a where method.

    dhruvasagar committed Apr 20, 2013
    Copy the full SHA
    7be6f06 View commit details

Commits on May 24, 2013

  1. Merge pull request maccman#23 from felafelwaffle/master

    Relax pinned rails dependencies so that gem works with all 3.x and above rails versions
    maccman committed May 24, 2013
    Copy the full SHA
    76cfbc3 View commit details

Commits on Jun 13, 2013

  1. Merge pull request maccman#24 from dhruvasagar/master

    Added #where to base.rb
    maccman committed Jun 13, 2013
    Copy the full SHA
    6d8a927 View commit details

Commits on Jul 10, 2013

  1. updated to rails 3.1

    rsds143 committed Jul 10, 2013
    Copy the full SHA
    ac60d6e View commit details

Commits on Aug 19, 2014

  1. Copy the full SHA
    fbd603a View commit details

Commits on Sep 16, 2014

  1. Merge pull request maccman#25 from felafelwaffle/felafelwaffle-rails-…

    …4-support
    
    Rails 4 compatibility
    maccman committed Sep 16, 2014
    Copy the full SHA
    628f4c5 View commit details

Commits on Aug 16, 2016

  1. Upgraded rails version.

    Emma Beaton committed Aug 16, 2016
    Copy the full SHA
    acb7ac6 View commit details
  2. Merge pull request #1 from ReaxDev/chore/upgrade_ruby_version

    Upgraded rails version.
    Emma Beaton authored Aug 16, 2016
    Copy the full SHA
    71dc33f View commit details
  3. Removed rails.

    Emma Beaton committed Aug 16, 2016
    Copy the full SHA
    7f27713 View commit details
  4. Merge pull request maccman#2 from ReaxDev/chore/fix_rails_installation

    Removed rails.
    Emma Beaton authored Aug 16, 2016
    Copy the full SHA
    449e590 View commit details

Commits on Aug 17, 2016

  1. Merge branch 'master' of github.com:maccman/supermodel

    * 'master' of github.com:maccman/supermodel:
      prefer calling actual rails callbacks API method over private rails method
      Added a where method.
      updating to support all rails versions 3.0+
      Fixed small typo in comment in base.rb
      do not dup known_attributes
      remove serialize_options
      no dups
      primary key
      removing attr_accessor_with_default
      attempt to fix for rails 3.1
      fixing dependecy issue
      removed deprecated class_inheritable_attribute and replaced_with class_attribute
      Encapsulate UniquenessValidator in SuperModel namespace instead of directly monkeypatching ActiveModel.
    
    # Conflicts:
    #	supermodel.gemspec
    Sean Hill committed Aug 17, 2016
    Copy the full SHA
    db5cb55 View commit details
Showing with 50 additions and 97 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 Gemfile
  3. +15 −11 Gemfile.lock
  4. +1 −1 VERSION
  5. +0 −64 lib/active_model/serialize_options.rb
  6. +1 −6 lib/supermodel.rb
  7. +23 −6 lib/supermodel/base.rb
  8. +2 −2 lib/supermodel/callbacks.rb
  9. +6 −6 supermodel.gemspec
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -4,3 +4,4 @@ redis_test.rb
pkg
lib/supermodel/cassandra.rb
*.gem
tags
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source :rubygems

gemspec
gemspec
26 changes: 15 additions & 11 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
PATH
remote: .
specs:
supermodel (0.1.4)
activemodel (~> 3.0.0)
csun-student-affairs-supermodel (0.1.6)
activemodel (~> 3.2.1)

GEM
remote: http://rubygems.org/
specs:
activemodel (3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
i18n (~> 0.4)
activesupport (3.0.4)
builder (2.1.2)
i18n (0.5.0)
activemodel (3.2.22.4)
activesupport (= 3.2.22.4)
builder (~> 3.0.0)
activesupport (3.2.22.4)
i18n (~> 0.6, >= 0.6.4)
multi_json (~> 1.0)
builder (3.0.4)
i18n (0.7.0)
multi_json (1.12.1)

PLATFORMS
ruby

DEPENDENCIES
activemodel (~> 3.0.0)
supermodel!
csun-student-affairs-supermodel!

BUNDLED WITH
1.12.5
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.4
0.1.7
64 changes: 0 additions & 64 deletions lib/active_model/serialize_options.rb

This file was deleted.

7 changes: 1 addition & 6 deletions lib/supermodel.rb
Original file line number Diff line number Diff line change
@@ -2,15 +2,14 @@
gem "activemodel"

require "active_support/core_ext/class/attribute_accessors"
require "active_support/core_ext/class/inheritable_attributes"
require "active_support/core_ext/hash/indifferent_access"
require "active_support/core_ext/kernel/reporting"
require "active_support/core_ext/module/attr_accessor_with_default"
require "active_support/core_ext/module/delegation"
require "active_support/core_ext/module/aliasing"
require "active_support/core_ext/object/blank"
require "active_support/core_ext/object/try"
require "active_support/core_ext/object/to_query"
require "active_support/core_ext/class/attribute"
require "active_support/json"

require "active_model"
@@ -35,8 +34,4 @@ module SuperModel
autoload :Dirty, "supermodel/dirty"
autoload :Redis, "supermodel/redis"
autoload :Base, "supermodel/base"
end

module ActiveModel
autoload :SerializeOptions, "active_model/serialize_options"
end
29 changes: 23 additions & 6 deletions lib/supermodel/base.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
module SuperModel
class Base
class_inheritable_array :known_attributes
class_attribute :known_attributes
self.known_attributes = []

class << self
attr_accessor_with_default(:primary_key, 'id') #:nodoc:
attr_accessor(:primary_key) #:nodoc:

def primary_key
@primary_key ||= 'id'
end

def collection(&block)
@collection ||= Class.new(Array)
@@ -13,7 +17,7 @@ def collection(&block)
end

def attributes(*attributes)
self.known_attributes += attributes.map(&:to_s)
self.known_attributes |= attributes.map(&:to_s)
end

def records
@@ -50,6 +54,19 @@ def last
item = records.values[-1]
item && item.dup
end

def where(options)
items = records.values.select do |r|
options.all? do |k, v|
if v.is_a?(Enumerable)
v.include?(r.send(k))
else
r.send(k) == v
end
end
end
collection.new(items.deep_dup)
end

def exists?(id)
records.has_key?(id)
@@ -76,7 +93,7 @@ def destroy(id)
end

# Removes all records and executes
# destory callbacks.
# destroy callbacks.
def destroy_all
all.each {|r| r.destroy }
end
@@ -120,7 +137,7 @@ def method_missing(method_symbol, *args) #:nodoc:
attr_writer :new_record

def known_attributes
self.class.known_attributes + self.attributes.keys.map(&:to_s)
self.class.known_attributes | self.attributes.keys.map(&:to_s)
end

def initialize(attributes = {})
@@ -306,4 +323,4 @@ class Base
include Dirty, Observing, Callbacks, Validations
include Association::Model
end
end
end
4 changes: 2 additions & 2 deletions lib/supermodel/callbacks.rb
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ module Callbacks
%w( create save update destroy ).each do |method|
class_eval(<<-EOS, __FILE__, __LINE__ + 1)
def #{method}_with_callbacks(*args, &block)
_run_#{method}_callbacks do
run_callbacks :#{method} do
#{method}_without_callbacks(*args, &block)
end
end
@@ -20,4 +20,4 @@ def #{method}_with_callbacks(*args, &block)
end
end
end
end
end
12 changes: 6 additions & 6 deletions supermodel.gemspec
Original file line number Diff line number Diff line change
@@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{csun-student-affairs-supermodel}
s.version = "0.1.5"
s.version = "0.1.7"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Alex MacCaw", "Mani Tadayon"]
s.date = %q{2010-08-30}
s.date = %q{2013-07-08}
s.description = %q{In memory DB using ActiveModel}
s.email = %q{info@eribium.org}
s.extra_rdoc_files = [
@@ -48,11 +48,11 @@ Gem::Specification.new do |s|
s.specification_version = 3

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<activemodel>, ["~> 3.0.0"])
s.add_runtime_dependency(%q<activemodel>, [">= 3.0.0"])
else
s.add_dependency(%q<activemodel>, ["~> 3.0.0"])
s.add_dependency(%q<activemodel>, [">= 3.0.0"])
end
else
s.add_dependency(%q<activemodel>, ["~> 3.0.0"])
s.add_dependency(%q<activemodel>, [">= 3.0.0"])
end
end
end