Dinodex

Refactored dinodex to simplify usage and make it more readable/usable
Changed filter on dinodex to array instead of hash to allow filtering on same data
Removed method_missing for define_method
cleaned up dino to be less copy/pasty
Ahh, missed that. Good call.

Joseph Mastey
jmmastey@gmail.com | 815.228.6924 | http://josephmastey.com |
http://leveluprails.herokuapp.com

On Thu, Sep 25, 2014 at 11:44 AM, Przemek Wojtowicz <
notifications@github.com> wrote:

> In dino_catalog/dino.rb:
>
> > @@ -0,0 +1,46 @@
> > +require "json"
> > +
> > +class Dino
> > +  attr_reader :name, :period, :continent, :diet, :carnivore, :weight,
> > +    :walking, :description
> > +
> > +  def initialize(params = {})
> > +    params.each { |key, value| instance_variable_set("@#{key}", value) }
> > +    raise "Dino name is reqired parameter." unless @name
> > +    @weight = @weight.to_f if @weight
> > +  end
> > +
> > +  def match?(criteria)
> > +    criteria.all? do |field, value|
> > +      match(send(field), value) if respond_to?(field)
>
> Wouldn't that just evaluate to nil which is false?
>
> irb(main):009:0* true if false
> => nil
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/jmmastey/level_up_exercises/pull/84/files#r18043692>.
>