Sha256: fd21ace8aa6006a6c6cb5ed3f1a5331427a06dba4b25b509ee9398729a32018b

Contents?: true

Size: 753 Bytes

Versions: 24

Compression:

Stored size: 753 Bytes

Contents

rad.html

# Converts {'model[attribute]' => value} into {'model' => {'attribute' => value}}
class ScopedParams < Rad::Conveyors::Processor      
  def call
    if workspace.params?
      to_delete = []
      to_add = {}
      workspace.params.each do |name, value|
        name.to_s.scan /(.+)\[(.+)\]/ do |scope_name, name_in_scope|
          logger.warn "RAD owerriding :#{scope} param!" if workspace.params.include? scope_name              
          scope = to_add[scope_name.to_sym] ||= {}                          
          scope[name_in_scope] = value
          to_delete << name
        end
      end
      workspace.params.merge! to_add
      to_delete.each{|n| workspace.params.delete n}
    end
            
    next_processor.call
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rad_core-0.2.6 lib/rad/html/processors/scoped_params.rb
rad_core-0.2.5 lib/rad/html/processors/scoped_params.rb
rad_core-0.2.4 lib/rad/html/processors/scoped_params.rb
rad_core-0.2.3 lib/rad/html/processors/scoped_params.rb
rad_core-0.2.2 lib/rad/html/processors/scoped_params.rb
rad_core-0.2.1 lib/rad/html/processors/scoped_params.rb
rad_core-0.2.0 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.30 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.29 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.28 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.27 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.26 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.25 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.24 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.23 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.22 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.21 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.20 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.19 lib/rad/html/processors/scoped_params.rb
rad_core-0.0.18 lib/rad/html/processors/scoped_params.rb