Module: Tripod::Fields::ClassMethods
- Defined in:
- lib/tripod/fields.rb
Instance Method Summary collapse
-
#field(name, predicate, options = {}) ⇒ Field
Defines all the fields that are accessible on the Resource For each field that is defined, a getter and setter will be added as an instance method to the Resource.
- #new_value_for_field(value, field) ⇒ Object
Instance Method Details
#field(name, predicate, options = {}) ⇒ Field
Defines all the fields that are accessible on the Resource For each field that is defined, a getter and setter will be added as an instance method to the Resource.
@option options [ String, RDF::URI ] datatype The uri of the datatype for the field (will be used to create an RDF::Literal of the right type on the way in only).
30 31 32 33 |
# File 'lib/tripod/fields.rb', line 30 def field(name, predicate, = {}) # TODO: validate the field params/options here.. add_field(name, predicate, ) end |
#new_value_for_field(value, field) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/tripod/fields.rb', line 36 def new_value_for_field(value, field) if field.is_uri? RDF::URI.new(value.to_s) elsif field.datatype RDF::Literal.new(value, :datatype => field.datatype) else value end end |