Skip to content
Browse files

replaced named_scope with scope, and updated version

  • Loading branch information...
1 parent d6ff21d commit c9e597891eb4bb1d13877a926ccf15bee46fe357 @stuzart stuzart committed May 8, 2013
Showing with 13 additions and 13 deletions.
  1. +1 −1 VERSION.yml
  2. +6 −6 lib/app/models/annotation.rb
  3. +4 −4 lib/app/models/annotation_value_seed.rb
  4. +2 −2 my_annotations.gemspec
View
2 VERSION.yml
@@ -1,4 +1,4 @@
---
:major: 0
-:minor: 5
+:minor: 6
:patch: 0
View
12 lib/app/models/annotation.rb
@@ -75,41 +75,41 @@ def value_content
# Named scope to allow you to include the value records too.
# Use this to *potentially* improve performance.
- named_scope :include_values, lambda {
+ scope :include_values, lambda {
{ :include => [ :value ] }
}
# Finder to get all annotations by a given source.
- named_scope :by_source, lambda { |source_type, source_id|
+ scope :by_source, lambda { |source_type, source_id|
{ :conditions => { :source_type => source_type,
:source_id => source_id },
:order => "created_at DESC" }
}
# Finder to get all annotations for a given annotatable.
- named_scope :for_annotatable, lambda { |annotatable_type, annotatable_id|
+ scope :for_annotatable, lambda { |annotatable_type, annotatable_id|
{ :conditions => { :annotatable_type => annotatable_type,
:annotatable_id => annotatable_id },
:order => "created_at DESC" }
}
# Finder to get all annotations with a given attribute_name.
- named_scope :with_attribute_name, lambda { |attrib_name|
+ scope :with_attribute_name, lambda { |attrib_name|
{ :conditions => { :annotation_attributes => { :name => attrib_name } },
:joins => :attribute,
:order => "created_at DESC" }
}
# Finder to get all annotations with one of the given attribute_names.
- named_scope :with_attribute_names, lambda { |attrib_names|
+ scope :with_attribute_names, lambda { |attrib_names|
conditions = [attrib_names.collect{"annotation_attributes.name = ?"}.join(" or ")] | attrib_names
{ :conditions => conditions,
:joins => :attribute,
:order => "created_at DESC" }
}
# Finder to get all annotations for a given value_type.
- named_scope :with_value_type, lambda { |value_type|
+ scope :with_value_type, lambda { |value_type|
{ :conditions => { :value_type => value_type },
:order => "created_at DESC" }
}
View
8 lib/app/models/annotation_value_seed.rb
@@ -12,27 +12,27 @@ class AnnotationValueSeed < ActiveRecord::Base
# Named scope to allow you to include the value records too.
# Use this to *potentially* improve performance.
- named_scope :include_values, lambda {
+ scope :include_values, lambda {
{ :include => [ :value ] }
}
# Finder to get all annotation value seeds with a given attrib_name.
- named_scope :with_attribute_name, lambda { |attrib_name|
+ scope :with_attribute_name, lambda { |attrib_name|
{ :conditions => { :annotation_attributes => { :name => attrib_name } },
:joins => :attribute,
:order => "created_at DESC" }
}
# Finder to get all annotation value seeds with one of the given attrib_names.
- named_scope :with_attribute_names, lambda { |attrib_names|
+ scope :with_attribute_names, lambda { |attrib_names|
conditions = [attrib_names.collect{"annotation_attributes.name = ?"}.join(" or ")] | attrib_names
{ :conditions => conditions,
:joins => :attribute,
:order => "created_at DESC" }
}
# Finder to get all annotations for a given value_type.
- named_scope :with_value_type, lambda { |value_type|
+ scope :with_value_type, lambda { |value_type|
{ :conditions => { :value_type => value_type },
:order => "created_at DESC" }
}
View
4 my_annotations.gemspec
@@ -2,8 +2,8 @@ require 'rake'
Gem::Specification.new do |s|
s.name = 'my_annotations'
- s.version = '0.5.1'
- s.date = '2013-05-02'
+ s.version = '0.6.0'
+ s.date = '2013-05-08'
s.summary = "This gem allows arbitrary metadata and relationships to be stored and retrieved, in the form of Annotations for any model objects in your Ruby on Rails (v2.2+) application."
s.description = "This gem allows arbitrary metadata and relationships to be stored and retrieved, in the form of Annotations for any model objects in your Ruby on Rails (v2.2+) application."
s.authors = ["Jiten Bhagat","Stuart Owen","Quyen Nguyen"]

0 comments on commit c9e5978

Please sign in to comment.
Something went wrong with that request. Please try again.