disposable 0.2.0.rc1 → 0.2.0.rc2

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: a33b386392c77411ef19323562c9f0bb3b31761c
4
- data.tar.gz: 789982e39d11feb8a4550e93452ca8d9ba91ac07
3
+ metadata.gz: dc1db64d77739d1da5e821cedc6c1bde7d3f8bbd
4
+ data.tar.gz: 05f481a9db8f68cffe17779c24188b1033d6b00e
5
5
  SHA512:
6
- metadata.gz: eb94a6c5097a5b380011f9a6cf6f6b02081b058842751110beec5b2f82cc37fc088f08d8b3ea2b8fb3d87e8607c9e44acc446d52470394f4ca27736cf8c29891
7
- data.tar.gz: d11e58f841ecccfb165f6c48e6ddeb65eb3e9fe8b4aade955b6fc906bd056abc63589c9d42f05c1a35effb45becd6d0a6a616a171c81797d28fce1ac871895cf
6
+ metadata.gz: 1d619d15d0fcd6d09ca57c6438fe160a3f174dd494e933bb1ffec7bbd155d5eca5f89aa2c071efd9b54e645fa1cf36d97728b0bca51948d842918c0be48cbd7f
7
+ data.tar.gz: 67a7a1e451a6c867446a374bfe504932d70b31e5446ad419832e75db1428f28ff3d7080b753c651962976ce004714f289fdf4e373a578a899d798f67999533cd
data/CHANGES.md CHANGED
@@ -4,6 +4,8 @@
4
4
  * `Twin::representer_class.representable_attrs` is now `Twin::definitions`.
5
5
  * `Disposable::Twin::Schema` is now `Disposable::Rescheme`. Renamed its `:representer_from` option to `:definitions_from`.
6
6
  * `twin: Twin::Song` is the only way to specify an external twin. To reduce complexity, I've removed the lambda version of `:twin`.
7
+ * Added `:exclude_properties` to `Rescheme`.
8
+ * Runs with Representable 2.4 and 3.0.
7
9
 
8
10
  # 0.1.14
9
11
 
data/Gemfile CHANGED
@@ -2,7 +2,8 @@ source "https://rubygems.org"
2
2
  gemspec
3
3
 
4
4
  # gem "representable", path: "../representable"
5
- gem "representable", github: "apotonick/representable"
5
+ gem "representable", "2.4.0.rc5"
6
+ # gem "representable", github: "apotonick/representable"
6
7
  # gem "declarative", path: "../declarative"
7
8
  # gem "declarative", github: "apotonick/declarative"
8
9
  gem "minitest-line"
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'disposable/version'
@@ -20,7 +19,7 @@ Gem::Specification.new do |spec|
20
19
 
21
20
  spec.add_dependency "uber"
22
21
  spec.add_dependency "declarative", "~> 0.0.4"
23
- spec.add_dependency "representable", ">= 2.4.0.rc1", "< 2.5.0"
22
+ spec.add_dependency "representable", ">= 2.4.0.rc5", "<= 3.1.0"
24
23
 
25
24
  spec.add_development_dependency "bundler", "~> 1.3"
26
25
  spec.add_development_dependency "rake"
@@ -19,6 +19,8 @@ class Disposable::Rescheme
19
19
  definitions = options[:definitions_from].call(source_class)
20
20
 
21
21
  definitions.each do |dfn|
22
+ next if (options[:exclude_properties]||{}).include?(dfn[:name].to_sym)
23
+
22
24
  dfn = build_definition!(options, dfn, representer, &block)
23
25
  evaluate_block!(options, dfn, &block)
24
26
  end
@@ -12,8 +12,8 @@
12
12
  def sync_hash_representer # TODO: make this without representable, please.
13
13
  Sync.hash_representer(self.class) do |dfn|
14
14
  dfn.merge!(
15
- prepare: lambda { |model, *| model },
16
- serialize: lambda { |model, *| model.sync! },
15
+ prepare: lambda { |options| options[:input] },
16
+ serialize: lambda { |options| options[:input].sync! },
17
17
  representable: true
18
18
  ) if dfn[:nested]
19
19
  end
@@ -3,6 +3,7 @@
3
3
  # 2. call sync! on nested
4
4
  #
5
5
  # Note: #sync currently implicitly saves AR objects with collections
6
+ require 'ostruct'
6
7
  class Disposable::Twin
7
8
  module Sync
8
9
  class Options < ::Hash
@@ -93,8 +94,8 @@ class Disposable::Twin
93
94
  )
94
95
 
95
96
  dfn.merge!(
96
- prepare: lambda { |model, *| model }, # TODO: why do we need that here?
97
- serialize: lambda { |form, args| form.to_nested_hash },
97
+ prepare: lambda { |options| options[:input] }, # TODO: why do we need that here?
98
+ serialize: lambda { |options| options[:input].to_nested_hash },
98
99
  ) if dfn[:nested]
99
100
  end
100
101
  end # #build_nested_hash_representer
@@ -1,3 +1,3 @@
1
1
  module Disposable
2
- VERSION = "0.2.0.rc1"
2
+ VERSION = "0.2.0.rc2"
3
3
  end
@@ -100,6 +100,31 @@ class ReschemeTest < MiniTest::Spec
100
100
  decorator.representable_attrs.get(:title).inspect.must_equal "#<Representable::Definition ==>title @options={:writeable=>false, :name=>\"title\", :parse_filter=>[], :render_filter=>[]}>"
101
101
  decorator.representable_attrs.get(:songs).representer_module.representable_attrs.get(:name).inspect.must_equal "#<Representable::Definition ==>name @options={:as=>\"Name\", :deserializer=>{:skip_parse=>\"a crazy cool instance method\"}, :name=>\"name\", :parse_filter=>[], :render_filter=>[]}>"
102
102
  end
103
+
104
+ describe ":exclude_properties" do
105
+ module SmallRepresenter
106
+ include Representable
107
+
108
+ property :id
109
+ property :songs do
110
+ property :id
111
+ property :name, as: "Name"
112
+ end
113
+ end
114
+
115
+ it do
116
+ decorator = Disposable::Rescheme.from(SmallRepresenter,
117
+ include: [Representable::Hash],
118
+ superclass: Representable::Decorator,
119
+ definitions_from: lambda { |nested| nested.definitions },
120
+ recursive: true,
121
+ exclude_properties: [:id]
122
+ )
123
+
124
+ decorator.definitions.keys.must_equal ["songs"]
125
+ decorator.definitions.get(:songs).representer_module.definitions.keys.must_equal ["name"]
126
+ end
127
+ end
103
128
  end
104
129
 
105
130
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disposable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.rc1
4
+ version: 0.2.0.rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-04 00:00:00.000000000 Z
11
+ date: 2015-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uber
@@ -44,20 +44,20 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.4.0.rc1
48
- - - "<"
47
+ version: 2.4.0.rc5
48
+ - - "<="
49
49
  - !ruby/object:Gem::Version
50
- version: 2.5.0
50
+ version: 3.1.0
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - ">="
56
56
  - !ruby/object:Gem::Version
57
- version: 2.4.0.rc1
58
- - - "<"
57
+ version: 2.4.0.rc5
58
+ - - "<="
59
59
  - !ruby/object:Gem::Version
60
- version: 2.5.0
60
+ version: 3.1.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: bundler
63
63
  requirement: !ruby/object:Gem::Requirement