From 7256eebf22a7a654500ec8542ae35af62712a263 Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Thu, 30 Apr 2009 10:34:48 -0400 Subject: [PATCH] Bug 414: allow arrays and arrays of hashes to be passed to `table` etc. --- hobo/lib/hobo.rb | 12 ++++++++---- hobo/taglibs/rapid_core.dryml | 2 +- hobo/taglibs/rapid_support.dryml | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/hobo/lib/hobo.rb b/hobo/lib/hobo.rb index 8e30786..5fc75cb 100644 --- a/hobo/lib/hobo.rb +++ b/hobo/lib/hobo.rb @@ -86,10 +86,14 @@ module Hobo def get_field(object, field) return nil if object.nil? field_str = field.to_s - if field_str =~ /^\d+$/ - object[field.to_i] - else - object.send(field) + begin + return object.send(field) + rescue NoMethodError => ex + if field_str =~ /^\d+$/ + return object[field.to_i] + else + return object[field] + end end end diff --git a/hobo/taglibs/rapid_core.dryml b/hobo/taglibs/rapid_core.dryml index b4c2682..40f48d3 100644 --- a/hobo/taglibs/rapid_core.dryml +++ b/hobo/taglibs/rapid_core.dryml @@ -98,7 +98,7 @@ This will use `` as the tag in each table cell instead of `` - <%= this.member_class.view_hints.field_name(scope.field_name) %> + <%= this.member_class.try.view_hints.try.field_name(scope.try.field_name) %> diff --git a/hobo/taglibs/rapid_support.dryml b/hobo/taglibs/rapid_support.dryml index 8bc24b6..1fe9d61 100644 --- a/hobo/taglibs/rapid_support.dryml +++ b/hobo/taglibs/rapid_support.dryml @@ -90,7 +90,7 @@ This tag is in need of a review - it's a bit funky. field_names -= comma_split(skip) if skip scope.new_scope :field_name => nil, :field_path => nil do field_names.map do |n| - scope.field_name = n == "this" ? this.member_class.name : n.to_s.gsub("." , "_") + scope.field_name = n == "this" ? this.member_class.try.name : n.to_s.gsub("." , "_") scope.field_path = n parameters.default end -- 1.6.0.4