faceted 1.0.7 → 1.0.8

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
- 1.0.7
1
+ 1.0.8
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.0.7"
8
+ s.version = "1.0.8"
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 = "2012-11-28"
12
+ s.date = "2012-12-06"
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 = [
@@ -22,6 +22,7 @@ module Faceted
22
22
  # Instance methods =======================================================
23
23
 
24
24
  def initialize(args={})
25
+ self.excludes = args.delete('excludes') || args.delete(:excludes)
25
26
  unless args.empty?
26
27
  self.id = args[:id]
27
28
  initialize_with_object
@@ -35,6 +36,14 @@ module Faceted
35
36
  self.success = object.delete
36
37
  end
37
38
 
39
+ def excludes=(value)
40
+ @excludes = value.nil? ? [] : value.map(&:to_sym)
41
+ end
42
+
43
+ def excludes
44
+ @excludes
45
+ end
46
+
38
47
  def reinitialize_with_object(obj)
39
48
  obj.reload
40
49
  schema_fields.each{ |k| self.send("#{k}=", obj.send(k)) if obj.respond_to?(k) && self.send(:settable_field?, k) }
@@ -50,7 +59,7 @@ module Faceted
50
59
  end
51
60
 
52
61
  def schema_fields
53
- self.class.fields
62
+ self.class.fields - self.excludes
54
63
  end
55
64
 
56
65
  def to_hash
data/lib/faceted/model.rb CHANGED
@@ -41,7 +41,7 @@ module Faceted
41
41
  end
42
42
 
43
43
  def fields
44
- @fields ||= [:id]
44
+ @fields ||= [:id, :excludes]
45
45
  end
46
46
 
47
47
  def materialize(objects=[])
@@ -59,6 +59,16 @@ module MyApi
59
59
  musician.alive.should_not be_nil
60
60
  end
61
61
 
62
+ it 'excludes fields' do
63
+ musician = MyApi::Musician.new(:id => 1, :excludes => [:rating])
64
+ musician.schema_fields.include?(:rating).should be_false
65
+ end
66
+
67
+ it 'excludes relations' do
68
+ musician = MyApi::Musician.new(:id => 1, :excludes => [:birthplace])
69
+ musician.schema_fields.include?(:birthplace).should be_false
70
+ end
71
+
62
72
  end
63
73
 
64
74
  it 'overwrites values from its AR counterpart' do
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.0.7
4
+ version: 1.0.8
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: 2012-11-28 00:00:00.000000000 Z
13
+ date: 2012-12-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -181,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
181
  version: '0'
182
182
  segments:
183
183
  - 0
184
- hash: -931986488037696218
184
+ hash: -1963421351288044790
185
185
  required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  none: false
187
187
  requirements: