class Kartograph::Artist
Attributes
map[R]
Public Class Methods
new(map)
click to toggle source
# File lib/kartograph/artist.rb, line 5 def initialize(map) @map = map end
Public Instance Methods
build_properties(object, scope)
click to toggle source
# File lib/kartograph/artist.rb, line 22 def build_properties(object, scope) scoped_properties = scope ? properties.filter_by_scope(scope) : properties scoped_properties.each_with_object({}) do |property, mapped| begin mapped[property.key] = property.value_for(object, scope) rescue NoMethodError => e raise ArgumentError, "#{object} does not respond to #{property.name}, so we can't map it" end end end
draw(object, scope = nil)
click to toggle source
# File lib/kartograph/artist.rb, line 13 def draw(object, scope = nil) if map.cache cache_key = map.cache_key.call(object, scope) map.cache.fetch(cache_key) { build_properties(object, scope) } else build_properties(object, scope) end end
properties()
click to toggle source
# File lib/kartograph/artist.rb, line 9 def properties map.properties end