class Cartograph::Sculptor
Attributes
map[R]
object[R]
Public Class Methods
new(object, map)
click to toggle source
# File lib/cartograph/sculptor.rb, line 5 def initialize(object, map) @object = object @map = map @sculpted_object = nil end
Public Instance Methods
properties()
click to toggle source
# File lib/cartograph/sculptor.rb, line 11 def properties map.properties end
sculpt(scope = nil)
click to toggle source
# File lib/cartograph/sculptor.rb, line 23 def sculpt(scope = nil) return unless @object scoped_properties = scope ? properties.filter_by_scope(scope) : properties attributes = scoped_properties.each_with_object({}) do |property, h| h[property.name] = property.value_from(object, scope) end return map.mapping.new(attributes) unless @sculpted_object attributes.each do |name, val| @sculpted_object[name] = val end @sculpted_object end
sculpted_object=(object)
click to toggle source
Set this to pass in an object to extract into. Must @param object must be of the same class as the map#mapping
# File lib/cartograph/sculptor.rb, line 17 def sculpted_object=(object) raise ArgumentError unless object.is_a?(map.mapping) @sculpted_object = object end