faceted 1.3.1 → 1.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/faceted.gemspec +2 -2
- data/lib/faceted/presenter.rb +2 -2
- data/spec/presenter_spec.rb +20 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.2
|
data/faceted.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "faceted"
|
8
|
-
s.version = "1.3.
|
8
|
+
s.version = "1.3.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Corey Ehmke", "Max Thom Stahl"]
|
12
|
-
s.date = "2013-
|
12
|
+
s.date = "2013-03-11"
|
13
13
|
s.description = "Faceted provides set of tools, patterns, and modules for use in API implementations."
|
14
14
|
s.email = "corey@trunkclub.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/faceted/presenter.rb
CHANGED
@@ -22,12 +22,12 @@ module Faceted
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def presents(name, args={})
|
25
|
-
class_name = args[:class_name] || name.to_s.classify
|
25
|
+
class_name = args[:class_name] || name.to_s.classify # LineItem
|
26
26
|
@presents = eval(class_name)
|
27
27
|
define_method :find_by do
|
28
28
|
args[:find_by] || :id
|
29
29
|
end
|
30
|
-
define_method :"#{
|
30
|
+
define_method :"#{name}" do
|
31
31
|
object
|
32
32
|
end
|
33
33
|
end
|
data/spec/presenter_spec.rb
CHANGED
@@ -21,6 +21,13 @@ class Album # and yet another make-believe AR model
|
|
21
21
|
def reload; self; end
|
22
22
|
end
|
23
23
|
|
24
|
+
class AlbumTrack
|
25
|
+
attr_accessor :id, :title
|
26
|
+
def initialize(params={}); params.each{|k,v| self.send("#{k}=",v) if self.respond_to?(k)}; end
|
27
|
+
def attributes; {:id => self.id, :title => self.name}; end
|
28
|
+
def reload; self; end
|
29
|
+
end
|
30
|
+
|
24
31
|
module MyApi
|
25
32
|
|
26
33
|
class Birthplace
|
@@ -45,6 +52,12 @@ module MyApi
|
|
45
52
|
field :name
|
46
53
|
end
|
47
54
|
|
55
|
+
class AlbumTrack
|
56
|
+
include Faceted::Presenter
|
57
|
+
presents :album_track
|
58
|
+
field :title
|
59
|
+
end
|
60
|
+
|
48
61
|
describe Musician do
|
49
62
|
|
50
63
|
before do
|
@@ -130,6 +143,13 @@ module MyApi
|
|
130
143
|
album.id.should == 1
|
131
144
|
end
|
132
145
|
|
146
|
+
it 'does not choke on associated objects with underscores in their names' do
|
147
|
+
@ar_album_track = ::AlbumTrack.new(:id => 1, :title => 'The Gambler')
|
148
|
+
::AlbumTrack.stub(:where) { [@ar_album_track] }
|
149
|
+
track = MyApi::AlbumTrack.new(:id => 1)
|
150
|
+
track.album_track.should == @ar_album_track
|
151
|
+
end
|
152
|
+
|
133
153
|
end
|
134
154
|
|
135
155
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faceted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -214,7 +214,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
214
214
|
version: '0'
|
215
215
|
segments:
|
216
216
|
- 0
|
217
|
-
hash:
|
217
|
+
hash: 4094991155632847834
|
218
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
219
|
none: false
|
220
220
|
requirements:
|