categoryz3 0.8.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31d94bc085b8197e984842edead40d0cb58158b6
4
- data.tar.gz: 1d28d5d98e907e6e7a70c02207b7bdb60331a28a
3
+ metadata.gz: 69526af5ee6719afe5a192596c08e14854349b0d
4
+ data.tar.gz: 2f3ceeec6fba79a8632aceb7828f5eb0841457e4
5
5
  SHA512:
6
- metadata.gz: 6df493751a559ac9fdad6bb224aaf38012b4bf371b09e9ea91e47e87e0515b381ff532d67802c47182031980396b12ef561f24c5d934307a07541fe7f0d4bdc2
7
- data.tar.gz: e8a7421f8c3577c0e9e4292f1a8326d907bb3f747760b89333d8b66d6eada234c28a685aba151c73664d9f91b9ac2a47556f4eb3b1f9a7f3c4850c787b226022
6
+ metadata.gz: 908aa26903456b8323248feac36cfc39e3aaba3ca6778d8976806cc62455697916e55854e38ba2e020b248f8bcfb43d2501da29c4fca2383f837406bc54a0a5a
7
+ data.tar.gz: a111b9674dbe7e13f7f8708298d8fce57aa36cb8bb31c0c2598ca7b50a0aa1ae5793982988b550f812080a51563f5acecb12614ad6eca3ba6be6b1b797b66021
data/README.rdoc CHANGED
@@ -2,6 +2,8 @@
2
2
  {<img src="https://secure.travis-ci.org/tscolari/categoryz3.png" />}[http://travis-ci.org/tscolari/categoryz3]
3
3
  {<img src="https://codeclimate.com/badge.png" />}[https://codeclimate.com/github/tscolari/categoryz3]
4
4
 
5
+ __Version 0.9+ is rails4 compatible__
6
+
5
7
  Simple categorization to ActiveRecord models.
6
8
 
7
9
  Works like a simple tagging system, but instead of tags it has categories, and categories may have an ilimited level of subcategories.
@@ -21,7 +21,7 @@ module Categoryz3
21
21
  # Private: Creates a child item for the category
22
22
  #
23
23
  def create_child_item_for_category(category)
24
- category.child_items.find_or_create_by_categorizable_type_and_categorizable_id_and_master_item_id(self.categorizable.class.base_class.name, self.categorizable.id, self.id)
24
+ category.child_items.find_or_create_by(categorizable_type: self.categorizable.class.base_class.name, categorizable_id: self.categorizable.id, master_item_id: self.id)
25
25
  end
26
26
 
27
27
  # Private: Create a child_item for each subcategory the category from this item have
@@ -14,11 +14,36 @@ module Categoryz3
14
14
  module Categorizable
15
15
  extend ActiveSupport::Concern
16
16
  included do
17
- has_many :direct_category_items , class_name: 'Categoryz3::Item' , as: :categorizable, inverse_of: :categorizable
18
- has_many :child_category_items , class_name: 'Categoryz3::ChildItem' , as: :categorizable, inverse_of: :categorizable
19
- has_many :categories, through: :direct_category_items, as: :categorizable, class_name: 'Categoryz3::Category'
20
- scope :inside_category , ->(category) { joins(:child_category_items).where('categoryz3_child_items.category_id = ?' , category.id) }
21
- scope :having_category , ->(category) { joins(:direct_category_items).where('categoryz3_items.category_id = ?' , category.id) }
17
+ has_many :direct_category_items,
18
+ class_name: 'Categoryz3::Item',
19
+ as: :categorizable,
20
+ inverse_of: :categorizable
21
+
22
+ has_many :child_category_items,
23
+ class_name: 'Categoryz3::ChildItem',
24
+ as: :categorizable,
25
+ inverse_of: :categorizable
26
+
27
+ has_many :categories,
28
+ through: :direct_category_items,
29
+ source: 'category',
30
+ class_name: 'Categoryz3::Category'
31
+
32
+ has_many :all_categories,
33
+ through: :child_category_items,
34
+ source: 'category',
35
+ class_name: 'Categoryz3::Category'
36
+
37
+ has_many :root_categories,
38
+ through: :child_category_items,
39
+ source: 'category',
40
+ class_name: 'Categoryz3::Category',
41
+ conditions: { parent_id: nil }
42
+
43
+ scope :inside_category ,
44
+ ->(category) { joins(:child_category_items).where('categoryz3_child_items.category_id = ?' , category.id) }
45
+ scope :having_category ,
46
+ ->(category) { joins(:direct_category_items).where('categoryz3_items.category_id = ?' , category.id) }
22
47
  end
23
48
 
24
49
  # Public: Removes a category, or categories, from the model
@@ -1,3 +1,3 @@
1
1
  module Categoryz3
2
- VERSION = "0.8.4"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: categoryz3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Scolari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-11 00:00:00.000000000 Z
11
+ date: 2013-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.2.0
19
+ version: 4.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.0
26
+ version: 4.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.0.0
129
+ rubygems_version: 2.0.3
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Simple categorization to ActiveRecord models.