Sha256: df69a67f2a564b3b03a2ebe3b88793526fa2b50d6ed2fb0dd6fde7ac72260883

Contents?: true

Size: 1.55 KB

Versions: 13

Compression:

Stored size: 1.55 KB

Contents

module Alchemy
  module ResourcesHelper

    def resource_window_size
      @resource_window_size ||= "400x#{100 + resource_handler.attributes.length * 35}"
    end

    def resource_instance_variable
      instance_variable_get("@#{resource_handler.model_name}")
    end

    def resources_instance_variable
      instance_variable_get("@#{resource_handler.resources_name}")
    end

    def resource_url_proxy
      if resource_handler.in_engine?
        eval(resource_handler.engine_name)
      else
        main_app
      end
    end

    def resource_scope
      @_resource_scope ||= [resource_url_proxy].concat(resource_handler.namespace_for_scope)
    end

    def resources_path(resource=resource_handler.model, options={})
      polymorphic_path (resource_scope + [resource]), options
    end

    def resource_path(resource=resource_handler.model, options={})
      resources_path(resource, options)
    end

    def new_resource_path(options={})
      new_polymorphic_path (resource_scope + [resource_handler.model]), options
    end

    def edit_resource_path(resource=nil, options={})
      edit_polymorphic_path (resource_scope+([resource] or model_array)), options
    end

    def resource_permission_scope
      resource_handler.permission_scope
    end

    def resource_model_name
      resource_handler.model_name
    end

    def resource_model
      resource_handler.model
    end

    def render_attribute(obj, attribute)
      attr_array = attribute.split('.')
      attr_array.each do |attr|
        obj = obj.send(attr) if obj
      end
      obj
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
alchemy_cms-2.3.2 lib/alchemy/resources_helper.rb
alchemy_cms-2.2.4 lib/alchemy/resources_helper.rb
alchemy_cms-2.3.1 lib/alchemy/resources_helper.rb
alchemy_cms-2.4.beta2 lib/alchemy/resources_helper.rb
alchemy_cms-2.2.3.2 lib/alchemy/resources_helper.rb
alchemy_cms-2.2.3.1 lib/alchemy/resources_helper.rb
alchemy_cms-2.3.0 lib/alchemy/resources_helper.rb
alchemy_cms-2.3.rc5 lib/alchemy/resources_helper.rb
alchemy_cms-2.2.2 lib/alchemy/resources_helper.rb
alchemy_cms-2.2.1 lib/alchemy/resources_helper.rb
alchemy_cms-2.2.0 lib/alchemy/resources_helper.rb
alchemy_cms-2.2.rc15 lib/alchemy/resources_helper.rb
alchemy_cms-2.2.rc14 lib/alchemy/resources_helper.rb