venduitz 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/venduitz/cache.rb +7 -1
- data/lib/venduitz/grape.rb +11 -4
- data/lib/venduitz/version.rb +1 -1
- data/lib/venduitz/view.rb +2 -2
- 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: d731579d5ab45c36f5817e0c32e81316392ee1ec
|
4
|
+
data.tar.gz: a333a6bdc74cec51e07740e22ce40092074c92de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e273ad146d03b28e72f35ef7b161c88cb5fc0558a86bd6f8e6566ec331aa4795b3f200b6c3db1162c19a54e9af5f2434091bf378d990120511ea3fbcd722c2
|
7
|
+
data.tar.gz: aa4272307be01665b92bd760616b51edb5e5a896def521c7a824bfb6e86c7a427ae7ee4a5c111a3dadfbf62dde72fa7ca4c72cf0cdb9a254aecdf589736f87b9
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/venduitz/cache.rb
CHANGED
@@ -6,7 +6,7 @@ module Venduitz
|
|
6
6
|
# Static methods
|
7
7
|
class << self
|
8
8
|
#
|
9
|
-
attr_accessor :digestor, :driver, :namespace
|
9
|
+
attr_accessor :digestor, :driver, :namespace, :enabled, :config
|
10
10
|
|
11
11
|
# Before use it you have to specify the driver used by
|
12
12
|
# this module. The driver must define the following
|
@@ -70,6 +70,12 @@ module Venduitz
|
|
70
70
|
@namespace.respond_to(:call) ? @namespace.call : @namespace
|
71
71
|
end
|
72
72
|
|
73
|
+
# Config
|
74
|
+
def config
|
75
|
+
return {} if @config.nil?
|
76
|
+
@config
|
77
|
+
end
|
78
|
+
|
73
79
|
private
|
74
80
|
|
75
81
|
def _driver
|
data/lib/venduitz/grape.rb
CHANGED
@@ -4,14 +4,21 @@ module Venduitz
|
|
4
4
|
module Grape
|
5
5
|
# Call method
|
6
6
|
def self.call(object, env)
|
7
|
-
#
|
8
|
-
|
7
|
+
# Route Options
|
8
|
+
options = env['api.endpoint'].options.fetch :route_options, {}
|
9
9
|
|
10
10
|
# Must define the Representer in the endpoint
|
11
|
-
raise 'Must define the Venduitz in the endpoind' if
|
11
|
+
raise 'Must define the Venduitz in the endpoind' if options[:venduitz].nil?
|
12
|
+
|
13
|
+
# Representer options
|
14
|
+
options[:exclude] ||= []
|
15
|
+
|
16
|
+
# Define the Cache options
|
17
|
+
options[:cache] ||= Venduitz::Cache.enabled
|
18
|
+
options[:cache_options] ||= Venduitz::Cache.config
|
12
19
|
|
13
20
|
# Render it!
|
14
|
-
|
21
|
+
options[:venduitz].to_json object, options[:exclude], options[:cache], options[:cache_options]
|
15
22
|
end
|
16
23
|
end
|
17
24
|
end
|
data/lib/venduitz/version.rb
CHANGED
data/lib/venduitz/view.rb
CHANGED
@@ -40,7 +40,7 @@ module Venduitz
|
|
40
40
|
# @param {Boolean} cache This flag indicates if cache will be performed
|
41
41
|
# @param {Hash} cache_options Cache options
|
42
42
|
# @return {Hash} JSON ready hash containing the specified view fields
|
43
|
-
def generate(obj, excluded = [], cache =
|
43
|
+
def generate(obj, excluded = [], cache = Cache.enabled, cache_options = Cache.config)
|
44
44
|
# Generate the cache key if cache is enabled
|
45
45
|
key = cache_key(obj, excluded, :generate) if cache
|
46
46
|
|
@@ -84,7 +84,7 @@ module Venduitz
|
|
84
84
|
# @param {Boolean} cache This flag indicates if cache will be performed
|
85
85
|
# @param {Hash} cache_options Cache options
|
86
86
|
# @return {Hash} The JSON string itself
|
87
|
-
def to_json(obj, excluded = [], cache =
|
87
|
+
def to_json(obj, excluded = [], cache = Cache.enabled, cache_options = Cache.config)
|
88
88
|
# Generate the cache key if cache is enabled
|
89
89
|
key = cache_key(obj, excluded, :json) if cache
|
90
90
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: venduitz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Corado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|