wedge 0.1.18 → 0.1.19

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: 3d5cba344b9b2d2cb5555b9eaf30132afd576c85
4
- data.tar.gz: 3f13558b89e8a9d960b417f7e792b96385e56992
3
+ metadata.gz: 743fe18c109f6fc6b16b080ed8513410c3a858d7
4
+ data.tar.gz: 80dd49ce133ea492f59f2984153312677e0b50a0
5
5
  SHA512:
6
- metadata.gz: 9d5d9ebb80b5aaf32d7bf2fa688176e34b45cfadb39eabdd58c5863351abbd0b5bfc1918ebf98dcd021d47a640742bac0c63fe566b7446fee3e55ea9c79e387b
7
- data.tar.gz: 428783e6058d34db64e503538d29851d04274570db989afa3775daf5b8d48148aa74bb2e229eab776102b99b06be09c89e0e35fb8e1e50b9c773834886b1d3bc
6
+ metadata.gz: eae83cd5489b454594342920755d20fe11d8bc7f6720875276668d022f086c36cb3511949c5173a9a1f75d91ef104caf1ccfd9cc441c5d525d423c4f0c1d9cea
7
+ data.tar.gz: 37db72b69386af0096898d6370d12d6a2ed6a78c2c97f9d35420d80c831bcc0d91c16ba21465a54a824457c7489d4deacd268a2d4ac1793275f1db35d5e0a7d2
data/TODO.md CHANGED
@@ -2,3 +2,4 @@
2
2
  - Cleanup plugin settings and make a plugin\_setting/settings method
3
3
  - Make it so the wedge config isn't passed down to all new components
4
4
  - more tests!
5
+ - Think of something better than Wedge.method_called / wedge_method_called
data/lib/wedge.rb CHANGED
@@ -26,7 +26,7 @@ class Wedge
26
26
  class << self
27
27
  extend Forwardable
28
28
 
29
- ATTR_ACCESSORS = %i{scope store config events}
29
+ ATTR_ACCESSORS = %i{scope store config events method_called}
30
30
 
31
31
  attr_accessor(*ATTR_ACCESSORS)
32
32
 
@@ -101,12 +101,13 @@ class Wedge
101
101
  end
102
102
 
103
103
  %w(store scope).each do |meth|
104
- define_method "#{meth}!" do |value|
104
+ define_method "#{meth}!" do |value, method_called = nil|
105
105
  klass = Class.new(self)
106
106
  ATTR_ACCESSORS.each do |name|
107
107
  klass.instance_variable_set(:"@#{name}", Wedge.instance_variable_get(:"@#{name}").deep_dup)
108
108
  end
109
109
  klass.instance_variable_set(:"@#{meth}", value.deep_dup)
110
+ klass.instance_variable_set(:"@method_called", method_called) if meth.to_s == 'scope'
110
111
  klass
111
112
  end
112
113
  end
@@ -4,12 +4,17 @@ class Wedge
4
4
  class Component
5
5
  include Methods
6
6
 
7
+ attr_accessor :wedge_method_called
8
+
7
9
  class << self
8
10
  attr_accessor :wedge_on_count
9
11
 
10
12
  def wedge_new(klass, *args, &block)
11
13
  obj = allocate
12
14
 
15
+ # discuss: come up with something better
16
+ obj.wedge_method_called = klass.method_called
17
+
13
18
  %w(store scope).each do |meth|
14
19
  if value = klass.send(meth)
15
20
  obj.config.send "#{meth}=", value
@@ -331,13 +336,19 @@ class Wedge
331
336
  alias_method :function, :wedge_function
332
337
 
333
338
  def wedge_from_server?
334
- begin; !request.try(:env).include?('HTTP_X_WEDGE_METHOD_REQUEST'); rescue; true end
339
+ begin
340
+ !(wedge_method_called == caller_locations(1,1)[0].label)
341
+ rescue
342
+ true
343
+ end
335
344
  end
336
345
  alias_method :from_server?, :wedge_from_server?
337
346
 
347
+ alias_method :method_called, :wedge_method_called
348
+
338
349
  def wedge_from_client?
339
350
  begin
340
- caller_locations(1,1)[0].label == request.try(:env)['HTTP_X_WEDGE_METHOD_REQUEST']
351
+ wedge_method_called == caller_locations(1,1)[0].label
341
352
  rescue
342
353
  false
343
354
  end
@@ -72,12 +72,12 @@ class Wedge
72
72
 
73
73
  if method_args == '__wedge_data__' && data
74
74
  method_args = [data]
75
- res = Wedge.scope!(scope)[name].send(method_called, *method_args) || ''
75
+ res = Wedge.scope!(scope, method_called)[name].send(method_called, *method_args) || ''
76
76
  else
77
77
  # This used to send things like init, we need a better way to
78
78
  # send client config data to the server
79
79
  # res = scope.wedge(name, data).send(method_called, *method_args) || ''
80
- res = Wedge.scope!(scope)[name].send(method_called, *method_args) || ''
80
+ res = Wedge.scope!(scope, method_called)[name].send(method_called, *method_args) || ''
81
81
  end
82
82
 
83
83
  # discuss: I don't think we should update the csrf token # every ajax call
data/lib/wedge/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Wedge
2
- VERSION = '0.1.18'
2
+ VERSION = '0.1.19'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wedge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-30 00:00:00.000000000 Z
11
+ date: 2015-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal