a_la_chart 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,10 @@ xml.instruct!
2
2
  xml.chart(chart_options.merge(:caption => params[:title])) do
3
3
  the_case = params[:case]
4
4
  data(the_case).each do |record|
5
- xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => next_color
5
+ xml.set
6
+ :value => value(record, :value, the_case),
7
+ :label => value(record, :label, the_case),
8
+ :link => value(record, :link, the_case),
9
+ :color => next_color
6
10
  end
7
11
  end
@@ -2,6 +2,10 @@ xml.instruct!
2
2
  xml.chart(chart_options.merge(:caption => params[:title])) do
3
3
  the_case = params[:case]
4
4
  data(the_case).each do |record|
5
- xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => next_color
5
+ xml.set
6
+ :value => value(record, :value, the_case),
7
+ :label => value(record, :label, the_case),
8
+ :link => value(record, :link, the_case),
9
+ :color => next_color
6
10
  end
7
11
  end
@@ -2,6 +2,10 @@ xml.instruct!
2
2
  xml.chart(chart_options.merge(:caption => params[:title])) do
3
3
  the_case = params[:case]
4
4
  data(the_case).each do |record|
5
- xml.set :value => value(record, :value, the_case), :label => value(record, :label, the_case), :link => value(record, :link, the_case), :color => next_color
5
+ xml.set
6
+ :value => value(record, :value, the_case),
7
+ :label => value(record, :label, the_case),
8
+ :link => value(record, :link, the_case),
9
+ :color => next_color
6
10
  end
7
11
  end
@@ -18,18 +18,20 @@ module ALaChart
18
18
  end
19
19
 
20
20
  def value(object, key, the_case=nil)
21
- return '' if object.blank?
21
+ return '' if object.blank? || key.blank?
22
22
 
23
23
  # if there is a meta map, use it. else try the key itself
24
24
  key_field = meta(the_case)[key] || key
25
25
 
26
+ return '' if key_field.present?
27
+
26
28
  if key_field.class == Proc
27
29
  val = key_field.call(object)
28
30
  elsif key_field.class == Fixnum
29
31
  val = object[key_field] if object.respond_to?('[]')
30
32
  else
31
- val = object.respond_to?(key_field) ? object.send(key_field) : nil
32
33
  val = object[key_field] if object.respond_to?('[]')
34
+ val = (object.respond_to?(key_field) ? object.send(key_field) : nil) if val.nil?
33
35
  val
34
36
  end
35
37
  end
data/lib/a_la_chart.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module ALaChart
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
4
4
 
5
5
  require File.join(File.dirname(__FILE__), 'a_la_chart', 'a_la_chart')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a_la_chart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Redmond