Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow an options hash to be passed to BlacklightMaps::GeojsonExport.new #60

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/helpers/blacklight/blacklight_maps_helper_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ def render_spatial_search_link coordinates
end

# pass the document or facet values to BlacklightMaps::GeojsonExport
def serialize_geojson(documents)
def serialize_geojson(documents, options={})
export = BlacklightMaps::GeojsonExport.new(controller,
controller.action_name,
documents)
documents,
options)
export.to_geojson
end

Expand Down
4 changes: 3 additions & 1 deletion lib/blacklight/maps/export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ class GeojsonExport
# response_docs is passed by a helper, and is either:
# - index view, map view: an array of facet values
# - show view: the document object
def initialize(controller, action, response_docs)
# options is an optional hash of possible configuration options
def initialize(controller, action, response_docs, options={})
@controller = controller
@action = action
@response_docs = response_docs
@options = options
end

# build the GeoJSON FeatureCollection
Expand Down
6 changes: 5 additions & 1 deletion spec/lib/blacklight/maps/export_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# TODO: use @response.facet_by_field_name('geojson').items instead of @response
# then refactor build_geojson_features and to_geojson specs
subject {BlacklightMaps::GeojsonExport.new(@controller, @action, @response.docs)}
subject {BlacklightMaps::GeojsonExport.new(@controller, @action, @response.docs, {foo:'bar'})}

it "should instantiate GeojsonExport" do
expect(subject.class).to eq(::BlacklightMaps::GeojsonExport)
Expand Down Expand Up @@ -46,6 +46,10 @@
expect(subject.send(:placename_property)).to eq('placename')
end

it "should create an @options instance variable" do
expect(subject.instance_variable_get("@options")[:foo]).to eq('bar')
end

end

describe "build_feature_from_geojson" do
Expand Down