class Cartograph::Artist
Attributes
map[R]
object[R]
Public Class Methods
new(object, map)
click to toggle source
# File lib/cartograph/artist.rb, line 5 def initialize(object, map) @object = object @map = map end
Public Instance Methods
build_properties(scope)
click to toggle source
# File lib/cartograph/artist.rb, line 23 def build_properties(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 raise ArgumentError, "#{object} does not respond to #{property.name}, so we can't map it" end end end
draw(scope = nil)
click to toggle source
# File lib/cartograph/artist.rb, line 14 def draw(scope = nil) if map.cache cache_key = map.cache_key.call(object, scope) map.cache.fetch(cache_key) { build_properties(scope) } else build_properties(scope) end end
properties()
click to toggle source
# File lib/cartograph/artist.rb, line 10 def properties map.properties end