🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

tree_decorator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tree_decorator

0.1.8
Rubygems
Version published
Maintainers
1
Created
Source

TreeDecorator

TreeDecorator has been designed to make it easier to decorate trees or nested sets of data. The tools provided, walk through a hash or nested object and apply code to containers and elements based on user defined rules.

For an example of how TreeDecorator can be used in Rails:

class Thing < ActiveRecord::Base
  acts_as_nested_set

  def name
    @name
  end
end

hanger = TreeDecorator::ObjectHanger.new(Thing.roots)

hanger.outer   {|content| content_tag('ul', content.html_safe)}
hanger.inner   {|content| content_tag('li', content.html_safe)}
hanger.element {|thing| link_to(thing.name, thing_path(thing))}

hanger.tree  #----> outputs a nested HTML unordered list with each thing's name 
             #      linking to it's default path.

See lib/example and tests for examples of usage

FAQs

Package last updated on 09 Apr 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts