mystique 0.5.5 → 0.5.6
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.
- checksums.yaml +4 -4
- data/lib/mystique.rb +2 -2
- data/lib/mystique/presenter.rb +6 -35
- data/lib/mystique/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbde41cbc026427231903de3d7c01d697018055f
|
|
4
|
+
data.tar.gz: 2d5cb47c000ab647b004844c2f4ff4f020cdb442
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 184110d5602a5acfaf10cfed601cb37475f7d40cba03cb685b32017b520abe8b7b2abf94dce47bf3e33a6483030b17e4337e96bb40f655e1c841a752935220a3
|
|
7
|
+
data.tar.gz: 90639ff21fb28cb47287b3ab65dd66fb4d8af28db40959a4f4158fb9087f0c872ef70fccf53f7bdbb9974270abd8206a1a85ca74947b0b4770f2cee5ec78abdb
|
data/lib/mystique.rb
CHANGED
|
@@ -14,11 +14,11 @@ module Mystique
|
|
|
14
14
|
when nil
|
|
15
15
|
begin
|
|
16
16
|
StringPlus.constantize("#{object.class}Presenter")
|
|
17
|
-
rescue NameError
|
|
17
|
+
rescue NameError
|
|
18
18
|
return object
|
|
19
19
|
end
|
|
20
20
|
when Symbol, String
|
|
21
|
-
StringPlus.constantize("#{with
|
|
21
|
+
StringPlus.constantize("#{with}Presenter")
|
|
22
22
|
else
|
|
23
23
|
with
|
|
24
24
|
end
|
data/lib/mystique/presenter.rb
CHANGED
|
@@ -9,7 +9,7 @@ module Mystique
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def initialize(object, context)
|
|
12
|
-
@__object__
|
|
12
|
+
@__object__ = object
|
|
13
13
|
@__context__ = context || self.class.context || NullContext
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -38,13 +38,6 @@ module Mystique
|
|
|
38
38
|
def method_missing(method, *args, &block)
|
|
39
39
|
return target.send(method, *args, &block) if method.to_s.start_with?("to_")
|
|
40
40
|
format( target.send(method, *args, &block) )
|
|
41
|
-
rescue NoMethodError => ex
|
|
42
|
-
if use_magic_brackets?
|
|
43
|
-
format(target.send(:[], *[method].concat(args), &block))
|
|
44
|
-
else
|
|
45
|
-
raise ex
|
|
46
|
-
end
|
|
47
|
-
|
|
48
41
|
end
|
|
49
42
|
|
|
50
43
|
def format(value)
|
|
@@ -57,9 +50,9 @@ module Mystique
|
|
|
57
50
|
else
|
|
58
51
|
value
|
|
59
52
|
end
|
|
60
|
-
Mystique.present(Callable(result).call(value, context))
|
|
53
|
+
Mystique.present(Callable(result).call(value, context))
|
|
61
54
|
end
|
|
62
|
-
|
|
55
|
+
|
|
63
56
|
def self.context(ctx=Undefined)
|
|
64
57
|
@__context__ = ctx unless ctx == Undefined
|
|
65
58
|
@__context__
|
|
@@ -75,36 +68,14 @@ module Mystique
|
|
|
75
68
|
end
|
|
76
69
|
end
|
|
77
70
|
|
|
78
|
-
def self.default_formats
|
|
79
|
-
if block_given?
|
|
80
|
-
@__default_formats__ = yield
|
|
81
|
-
else
|
|
82
|
-
@__default_formats__ ||= {}
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
def default_formats
|
|
87
|
-
Mystique::Presenter.default_formats
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
def self.use_magic_brackets
|
|
91
|
-
@__use_magic_brackets__ = true
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def self.use_magic_brackets?
|
|
95
|
-
@__use_magic_brackets__
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def use_magic_brackets?
|
|
99
|
-
self.class.use_magic_brackets?
|
|
100
|
-
end
|
|
101
|
-
|
|
102
71
|
def __formats__
|
|
103
72
|
self.class.__formats__
|
|
104
73
|
end
|
|
105
74
|
|
|
106
75
|
def self.__formats__
|
|
107
|
-
@__formats__ ||=
|
|
76
|
+
@__formats__ ||= {
|
|
77
|
+
nil => "-----",
|
|
78
|
+
}
|
|
108
79
|
end
|
|
109
80
|
|
|
110
81
|
def __regex_formats__
|
data/lib/mystique/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mystique
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Federico Iachetti
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
123
123
|
version: '0'
|
|
124
124
|
requirements: []
|
|
125
125
|
rubyforge_project:
|
|
126
|
-
rubygems_version: 2.
|
|
126
|
+
rubygems_version: 2.5.1
|
|
127
127
|
signing_key:
|
|
128
128
|
specification_version: 4
|
|
129
129
|
summary: Ruby presenter gem.
|