Sha256: 71c70bf8458266fb0833764a2cfad74dedd6d15f71c746e3f26f8dcbef6b2d0f

Contents?: true

Size: 1.55 KB

Versions: 7

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

7 entries across 7 versions & 1 rubygems

Version Path
alchemy_cms-2.4.1 lib/alchemy/resources_helper.rb
alchemy_cms-2.5.0.b5 lib/alchemy/resources_helper.rb
alchemy_cms-2.5.0.b2 lib/alchemy/resources_helper.rb
alchemy_cms-2.4.0 lib/alchemy/resources_helper.rb
alchemy_cms-2.4.rc4 lib/alchemy/resources_helper.rb
alchemy_cms-2.4.rc2 lib/alchemy/resources_helper.rb
alchemy_cms-2.4.rc1 lib/alchemy/resources_helper.rb