scoped_serializer 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/scoped_serializer/scope.rb +21 -0
- data/lib/scoped_serializer/serializer.rb +3 -0
- data/lib/scoped_serializer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c32261f4040ce1b81c7e955dc1e0122163cde4d
|
4
|
+
data.tar.gz: b84e63cf91a309ea2b683af89cc260ea51028506
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db2ffb1aa94ce0bf5e6d57187079ecd7fc993e1429a718f4a13050e3449752bb45abda201d1ca1ac44e256c5ac3142f861a052cb33c2ad40db28a949d14ea8ab
|
7
|
+
data.tar.gz: 44234ef5494e7eacd4ed8a77a30e0718d6f89254143d50c8f3a1add90be4f00540f314686753a6bc2b3c110afe22dca0cacca027d256d5ec0d8a6c112492f20c
|
@@ -5,6 +5,27 @@ module ScopedSerializer
|
|
5
5
|
|
6
6
|
attr_accessor :name, :attributes, :associations, :options
|
7
7
|
|
8
|
+
class << self
|
9
|
+
|
10
|
+
##
|
11
|
+
# Initializes a scope from hash.
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# Scope.from_hash({ :attributes => [:title, :created_at] })
|
15
|
+
#
|
16
|
+
def from_hash(data={})
|
17
|
+
scope = new self
|
18
|
+
scope.attributes *data[:attributes]
|
19
|
+
|
20
|
+
(data[:associations] || []).each do |association|
|
21
|
+
scope.association association
|
22
|
+
end
|
23
|
+
|
24
|
+
scope
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
8
29
|
def initialize(name, default=nil, &block)
|
9
30
|
@name = name
|
10
31
|
@options = {}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoped_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arjen Oosterkamp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|