Sha256: 86c330628894c3d1c122604efb09fe48fb43b86400d8c16c65f4bb295f4f3093

Contents?: true

Size: 1.34 KB

Versions: 37

Compression:

Stored size: 1.34 KB

Contents

module ExtJS::Controller

  def self.included(controller)
    controller.send(:extend, ClassMethods)
  end

  ##
  # Controller class methods
  #
  module ClassMethods

    def extjs_reader(model)
      {
        "successProperty" => extjs_success_property,
        "root" => extjs_root,
        "messageProperty" => extjs_message_property
      }.merge(model.extjs_record)
    end

    def extjs_proxy(params)
      proxy = {}
      if params[:proxy] === 'direct'
        actions = ['create', 'read', 'update', 'destroy']
        proxy["api"] = {}
        direct_actions.each_index do |n|
          proxy["api"][actions[n]] = direct_actions[n][:name]
        end
      else
        if params[:config]["api"]
          proxy["api"] = {}
          params[:config]["api"].each {|k,v| proxy["api"][k] = "/#{params[:controller]}/#{v}" }
        else
          proxy["url"] = "/#{params[:controller]}.#{params[:format].to_s}"
        end
      end
      proxy
    end

    def extjs_root(value=nil)
      ExtJS::MVC.root = value unless value.nil?
      ExtJS::MVC.root
    end

    def extjs_success_property(value=nil)
      ExtJS::MVC.success_property = value unless value.nil?
      ExtJS::MVC.success_property
    end

    def extjs_message_property(value=nil)
      ExtJS::MVC.message_property = value unless value.nil?
      ExtJS::MVC.message_property
    end

  end
end

Version data entries

37 entries across 37 versions & 3 rubygems

Version Path
extjs-extjs-mvc-0.1.8 lib/action_controller/controller.rb
extjs-extjs-mvc-0.1.9 lib/action_controller/controller.rb
extjs-mvc-0.1.12 lib/action_controller/controller.rb
extjs-mvc-0.1.13 lib/action_controller/controller.rb
extjs-mvc-0.1.14 lib/action_controller/controller.rb
extjs-mvc-0.1.15 lib/action_controller/controller.rb
extjs-mvc-0.1.16 lib/action_controller/controller.rb
extjs-mvc-0.1.17 lib/action_controller/controller.rb
extjs-mvc-0.1.18 lib/action_controller/controller.rb
extjs-mvc-0.1.19 lib/action_controller/controller.rb
extjs-mvc-0.1.2 lib/action_controller/controller.rb
extjs-mvc-0.1.20 lib/action_controller/controller.rb
extjs-mvc-0.1.22 lib/action_controller/controller.rb
extjs-mvc-0.1.23 lib/action_controller/controller.rb
extjs-mvc-0.1.24 lib/action_controller/controller.rb
extjs-mvc-0.1.25 lib/action_controller/controller.rb
extjs-mvc-0.1.5 lib/action_controller/controller.rb
extjs-mvc-0.1.6 lib/action_controller/controller.rb
extjs-mvc-0.1.7 lib/action_controller/controller.rb
extjs-mvc-0.1.9 lib/action_controller/controller.rb