netzke / netzke-core

Framework for Sencha Ext JS + Ruby on Rails client-server components
http://netzke.org
Other
263 stars 77 forks source link

Overriding scope in component declaration has no effect #61

Closed simonwmn closed 11 years ago

simonwmn commented 11 years ago

When a scope is set in component configuration:

class FooGrid < Grid
  def configure c
    super c
    c.scope = :foo_scope
  end
end

I am not able to override it via the component declaration:

component :foo_grid do |c|
  c.klass = FooGrid
  c.scope = :other_scope
end

As soon as I remove the scope from the configure method the scope supplied in the declaration will be honored.

Not entirely sure if basepack or core is at fault but I assume it has something to do with the merging mechanism of the different config layers so I reported it here.

mxgrn commented 11 years ago

It's about where you put super in configure. In this case, super sets the scope to what you pass in your component block, but then you override it by calling c.scope = :foo_scope. Either place that call before supper, or replace it with c.scope ||= :foo_scope.