Skip to content

Commit

Permalink
Add options back to Literal class initializers, as it may be used by …
Browse files Browse the repository at this point in the history
…subclasses from rdf-xsd.
  • Loading branch information
gkellogg committed Dec 31, 2016
1 parent 66da1c5 commit 78e5b79
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 14 deletions.
8 changes: 2 additions & 6 deletions lib/rdf/model/literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,7 @@ def self.new(value, language: nil, datatype: nil, lexical: nil, validate: false,
end
end
literal = klass.allocate
if klass.equal?(RDF::Literal)
literal.send(:initialize, value, language: language, datatype: datatype)
else
literal.send(:initialize, value, datatype: datatype)
end
literal.send(:initialize, value, language: language, datatype: datatype, **options)
literal.validate! if validate
literal.canonicalize! if canonicalize
literal
Expand Down Expand Up @@ -165,7 +161,7 @@ def self.new(value, language: nil, datatype: nil, lexical: nil, validate: false,
# @see http://www.w3.org/TR/rdf11-concepts/#section-Graph-Literal
# @see http://www.w3.org/TR/rdf11-concepts/#section-Datatypes
# @see #to_s
def initialize(value, language: nil, datatype: nil, lexical: nil, validate: false, canonicalize: false)
def initialize(value, language: nil, datatype: nil, lexical: nil, validate: false, canonicalize: false, **options)
@object = value.freeze
@string = lexical if lexical
@string = value if !defined?(@string) && value.is_a?(String)
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/boolean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Boolean < Literal
##
# @param [String, Boolean] value
# @param (see Literal#initialize)
def initialize(value, datatype: nil, lexical: nil)
def initialize(value, datatype: nil, lexical: nil, **options)
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
@string = lexical || (value if value.is_a?(String))
@object = case
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Date < Literal
##
# @param [String, Date, #to_date] value
# @param (see Literal#initialize)
def initialize(value, datatype: nil, lexical: nil)
def initialize(value, datatype: nil, lexical: nil, **options)
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
@string = lexical || (value if value.is_a?(String))
@object = case
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/datetime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DateTime < Literal
##
# @param [DateTime] value
# @option options [String] :lexical (nil)
def initialize(value, datatype: nil, lexical: nil)
def initialize(value, datatype: nil, lexical: nil, **options)
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
@string = lexical || (value if value.is_a?(String))
@object = case
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/decimal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Decimal < Numeric
##
# @param [String, BidDecimal, Numeric] value
# @param (see Literal#initialize)
def initialize(value, datatype: nil, lexical: nil)
def initialize(value, datatype: nil, lexical: nil, **options)
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
@string = lexical || (value if value.is_a?(String))
@object = case
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Double < Numeric
##
# @param [String, Float, #to_f] value
# @param (see Literal#initialize)
def initialize(value, datatype: nil, lexical: nil)
def initialize(value, datatype: nil, lexical: nil, **options)
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
@string = lexical || (value if value.is_a?(String))
@object = case
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Integer < Decimal
##
# @param [String, Integer, #to_i] value
# @param (see Literal#initialize)
def initialize(value, datatype: nil, lexical: nil)
def initialize(value, datatype: nil, lexical: nil, **options)
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
@string = lexical || (value if value.is_a?(String))
@object = case
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Time < Literal
##
# @param [String, DateTime, #to_datetime] value
# @param (see Literal#initialize)
def initialize(value, datatype: nil, lexical: nil)
def initialize(value, datatype: nil, lexical: nil, **options)
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
@string = lexical || (value if value.is_a?(String))
@object = case
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf/model/literal/token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Token < Literal
##
# @param [String, Symbol, #to_sym] value
# @param (see Literal#initialize)
def initialize(value, datatype: nil, lexical: nil)
def initialize(value, datatype: nil, lexical: nil, **options)
@datatype = RDF::URI(datatype || self.class.const_get(:DATATYPE))
@string = lexical || (value if value.is_a?(String))
@object = value.is_a?(Symbol) ? value : value.to_sym
Expand Down

0 comments on commit 78e5b79

Please sign in to comment.