Created
December 10, 2015 10:22
-
-
Save kryhtin/fd0c5e22425ad77100f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PropertiesLocationCollection | |
include ActionView::Helpers | |
include Rails.application.routes.url_helpers | |
def initialize(properties) | |
@properties = properties | |
end | |
def build | |
@locations = @properties.map do |property| | |
{ lat: property.owner.profile.location.lat.to_s, | |
lon: property.owner.profile.location.lon.to_s, | |
path: company_path(property.owner), | |
company: property.owner.profile.company_name.upcase } | |
end.uniq | |
end | |
def json | |
@locations.to_json | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment