sethyates-content_manager 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{content_manager}
5
- s.version = "0.2.0"
5
+ s.version = "0.3.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Seth Yates"]
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
23
23
  "init.rb",
24
24
  "lib/content_helper.rb",
25
25
  "lib/content_item.rb",
26
+ "lib/content_manager.rb",
26
27
  "lib/rack/content_manager.rb",
27
28
  "rails/init.rb",
28
29
  "test/content_manager_test.rb",
data/lib/content_item.rb CHANGED
@@ -36,15 +36,17 @@ class ContentItem
36
36
  }
37
37
  end
38
38
 
39
- def self.polymorphic_finder(name, *arguments)
40
- wrap_result(connection.query {|q| q.add_condition name.to_s, :eq, arguments.first.to_s })
39
+ def self.polymorphic_finder(which, name, *arguments)
40
+ hash = (connection.query {|q| q.add_condition name.to_s, :eq, arguments.first.to_s })
41
+ hash = hash.first if which == :first
42
+ wrap_result hash
41
43
  end
42
44
 
43
45
  def self.method_missing(name, *arguments)
44
46
  if name.to_s =~ /^find_all(_by)?_(.+)$/
45
- polymorphic_finder($2, arguments)
47
+ polymorphic_finder(:all, $2, arguments)
46
48
  elsif name.to_s =~ /^find_(first_by|by)_(.+)$/
47
- polymorphic_finder($2, arguments).first
49
+ polymorphic_finder(:first, $2, arguments)
48
50
  else
49
51
  super
50
52
  end
@@ -0,0 +1,3 @@
1
+ require 'content_item'
2
+ require 'content_helper'
3
+ require 'rack/content_manager'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sethyates-content_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Yates
@@ -42,6 +42,7 @@ files:
42
42
  - init.rb
43
43
  - lib/content_helper.rb
44
44
  - lib/content_item.rb
45
+ - lib/content_manager.rb
45
46
  - lib/rack/content_manager.rb
46
47
  - rails/init.rb
47
48
  - test/content_manager_test.rb