Skip to content

Commit 87f234c

Browse files
committed
allow for GeoScript::Feature to be isntantiated with passed in feature
1 parent 342d656 commit 87f234c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lib/geoscript/feature/feature.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
module GeoScript
55
class Feature
6-
def initialize(attrs = nil, id = nil, schema = nil, feature = nil)
7-
if attrs
6+
def initialize(attrs = nil, id = nil, schema = nil)
7+
raise 'No attributes specified for feature' unless attrs
8+
9+
if attrs.kind_of? GeoScript::Feature
810
unless schema
911
if attrs.instance_of? Hash
1012
schema_attrs = []
@@ -28,11 +30,9 @@ def initialize(attrs = nil, id = nil, schema = nil, feature = nil)
2830
sfb = SimpleFeatureBuilder.new @schema.feature_type
2931
attrs.each {|k, v| sfb.set(k, v)}
3032
@feature = sfb.build_feature id
31-
elsif feature
32-
@feature = feature
33-
@schema = schema ? schema : GeoScript::Schema.new(feature.feature_type)
3433
else
35-
raise 'No attributes specified for feature'
34+
@feature = attrs
35+
@schema = schema ? schema : GeoScript::Schema.new(@feature.feature_type)
3636
end
3737
end
3838

0 commit comments

Comments
 (0)