expo 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. data/lib/expo.rb +28 -5
  2. metadata +6 -4
  3. checksums.yaml +0 -15
data/lib/expo.rb CHANGED
@@ -1,4 +1,6 @@
1
+ require 'pry'
1
2
  class Expo
3
+ CALL_ORDER = [:summon, :aside, :expose, :sub_expo, :collection]
2
4
  def initialize(presenter=nil, &block)
3
5
  @presenter = presenter
4
6
  @block = block
@@ -6,6 +8,7 @@ class Expo
6
8
  @subs = {}
7
9
  @summons = {}
8
10
  @collections = {}
11
+ @inner_calls = []
9
12
  end
10
13
 
11
14
  def expo(object, context={})
@@ -18,6 +21,9 @@ class Expo
18
21
  return {}
19
22
  end
20
23
  block_return = self.instance_exec object, context, &@block
24
+ @inner_calls.sort_by{|call| CALL_ORDER.index(call[:method])}.each do |call|
25
+ self.send(call[:method], *call[:args], &call[:block])
26
+ end
21
27
  exposition = {}
22
28
  @message_map.each do |k,v|
23
29
  receiver = (@presenter || object)
@@ -35,13 +41,30 @@ class Expo
35
41
 
36
42
  private
37
43
 
38
- def sub_expo(object, sub_expo_passed, key)
44
+ def method_missing(meth, *args, &block)
45
+ return unless CALL_ORDER.include? meth
46
+
47
+ @inner_calls << {
48
+ method: "#{meth}_inner".to_sym,
49
+ args: args,
50
+ block: block
51
+ }
52
+ nil
53
+ end
54
+ def sub_expo_inner(object, sub_expo_passed, key)
55
+ if sub_expo_passed == self
56
+ p "1"
57
+ return
58
+ end
39
59
  sub = sub_expo_passed.expo(object, @context)
40
60
  @subs[key] = sub if sub
41
61
  nil
42
62
  end
43
63
 
44
- def collection(key, collection, item_expo)
64
+ def collection_inner(key, collection, item_expo)
65
+ if item_expo == self
66
+ return
67
+ end
45
68
  collection_exposition = []
46
69
  collection.each.with_index do |item, index|
47
70
  collection_exposition << item_expo.expo(item, @context.merge({
@@ -52,12 +75,12 @@ class Expo
52
75
  nil
53
76
  end
54
77
 
55
- def summon(*asides)
78
+ def summon_inner(*asides)
56
79
  @summons = hasherize(asides) {|aside| @context[aside]}
57
80
  nil
58
81
  end
59
82
 
60
- def aside(*messages)
83
+ def aside_inner(*messages)
61
84
  receiver = (@presenter || @object)
62
85
  last = messages.pop
63
86
  if last.is_a?(Hash)
@@ -73,7 +96,7 @@ class Expo
73
96
  nil
74
97
  end
75
98
 
76
- def expose(*messages)
99
+ def expose_inner(*messages)
77
100
  last = messages.pop
78
101
  if last.is_a?(Hash)
79
102
  @message_map.merge!(last)
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Serguei Filimonov
@@ -19,25 +20,26 @@ files:
19
20
  - lib/expo.rb
20
21
  homepage: https://github.com/sergueif/expo
21
22
  licenses: []
22
- metadata: {}
23
23
  post_install_message:
24
24
  rdoc_options: []
25
25
  require_paths:
26
26
  - lib
27
27
  required_ruby_version: !ruby/object:Gem::Requirement
28
+ none: false
28
29
  requirements:
29
30
  - - ! '>='
30
31
  - !ruby/object:Gem::Version
31
32
  version: '0'
32
33
  required_rubygems_version: !ruby/object:Gem::Requirement
34
+ none: false
33
35
  requirements:
34
36
  - - ! '>='
35
37
  - !ruby/object:Gem::Version
36
38
  version: '0'
37
39
  requirements: []
38
40
  rubyforge_project:
39
- rubygems_version: 2.0.3
41
+ rubygems_version: 1.8.24
40
42
  signing_key:
41
- specification_version: 4
43
+ specification_version: 3
42
44
  summary: Expo of object presentations
43
45
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZWRmZmVkZjVkYzE2YTU2OWY2MDliMGVmOTU3MWY3OGY1MTRlOTBhNA==
5
- data.tar.gz: !binary |-
6
- MTQxZGVlODdhOTI4YTdmZDZjMDJkYzY4M2U0MzZhODFlZmJiOTlhMg==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- Mjc2MjhiMjdlMWNlZWFhYjJiYzM4OWFkMTI1ZTg5YWNjZTg4YzcxNmY2ZDMy
10
- NzllZTRiMTM1MGFhMzdmMmRlNjUwMzQ5MjdmOTI2ODFhMGVhNWU4ODJmMTdi
11
- YTFlNGViZjYyNTJhYTA2Mzk0YWQ4ODE0ZWQzNTNjNTc4NDkxZDk=
12
- data.tar.gz: !binary |-
13
- NjdiY2YyMjYyNDY4ODIxMGQ4MDcxOTZlZWQ4YmRhMjgzNzAxZmM5MDU3ODli
14
- OTRmNjZmNzQ1NjYzNjU3Y2JiNmJhNzI1MjBlMzY2Mjc1YjI4NTQ5OTY1MTY1
15
- ZmNlNzg3YWM3ZjI5ZWY3ZTllY2Q0NzQ1ZTYzYTA2MDhkYjE1NWI=