Project

brototype

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby port of the popular brototypejs library.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 1.7
~> 10.0
>= 0
 Project Readme

Brototype

Bro, do you even Ruby?

This is a ruby port of the popular brototype.js library that can be found here: https://github.com/letsgetrandy/brototype

Features

You've got a deeply-nested set of objects that may or may not always be there. We've all seen something like this:

if params && params[:model] && params[:model][:id]
    # do something
end

We all hate that, don't we?

So what if you could just type:

Brototype::Bro.new(params).i_can_haz(:model,:id)

Or better yet, how about:

Brototype::Bro.new(params).i_dont_always(:model,:id).but_when_i do |id|
  puts id
end

Fetch nested properties by string or key:

Brototype::Bro.new(:foo => {:bar => 1}).i_can_haz(:foo,:bar)
Brototype::Bro.new('foo' => {'bar' => 1}).i_can_haz('foo','bar')

Handling exceptions

Brototype::Bro.new(@anon_class).brace_yourself('throws_error').here_come_the_errors do |e|
  puts 'error ' + e + ' happened.'
end

Installation

Add this line to your application's Gemfile:

gem 'brototype'

And then execute:

$ bundle

Or install it yourself as:

$ gem install brototype

Rspec is used to run the tests, just do:

rake spec

Contributing

  1. Fork it ( https://github.com/[my-github-username]/brototype/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request