Created
December 10, 2015 10:20
-
-
Save kryhtin/b3740a3b83c120edd746 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