Giter Club home page Giter Club logo

Comments (7)

cordawyn avatar cordawyn commented on August 23, 2024

@cagdasolgun I believe you meant rating.rates, not rating.target?

Anyway, your discovery can be considered a bug. The problem is that "has_many" association does not properly handle "in-place" changes. For now, you can use rating.rates = [celebrity] - this should work.

I'd also recommend to avoid using blank strings for resource identifiers (Celebrity.for("")), unless you're just playing around ;-)

Could you be more specific regarding "predicates with multiple ranges"? What does that mean?

from spira.

cagdasolgun avatar cagdasolgun commented on August 23, 2024

sorry about the issue. i updated it. :)
I'm trying to say rates is a predicate which defined in user domain and can take multiple types of ranges.
:rates rdfs:domain :user
:rates rdfs:range :celebrity
:rates rdfs:range :movie.

we can define multiple types(ranges) for properties.

And for Celebrity.for("") usage is my laziness:)

from spira.

cordawyn avatar cordawyn commented on August 23, 2024

Spira does not check the range constraints. That said, you should be able to throw anything into rates above. If you need to restrict the class(es) of the objects, you can do it with a validation hook, I guess.
However, if you feel like contributing a validates_range_of <predicate> or/and validates_domain_of <predicate>, you're most certainly welcome :) You may look-up "lib/spira/validations/uniqueness.rb" for reference.

from spira.

cagdasolgun avatar cagdasolgun commented on August 23, 2024

i'm considering about it:) We're migrating our project to spira. These validations and restrictions would be very usefull:)

from spira.

abrisse avatar abrisse commented on August 23, 2024

@cagdasolgun Any update ? A validates_range_of would be a great idea.

The problem with the multi-range is when building the rdf values from a RDF::Repository. Currently the meta range is read from the Class and used to initialize the new instance. With multiple range, which one to choose ?

Another solution, that I personnaly recommend, would be to use inheritance in your ontology, like mixins in Ruby. For example Celebrity and Movie could both inherit from Rateable that would become the new range of the property rates.

from spira.

cagdasolgun avatar cagdasolgun commented on August 23, 2024

Sorry for late reply,upto now no progress about this issue. But today i'm on it.

You dont need to choose type while creating individuals. Its a schematic problem. For ex:

:multiple rdfs:range xsd:string.
:multiple rdfs.range xsd:integer.


:individual1 :multiple "sring"^^xsd:string.
:individual2 :multiple 234^^xsd:integer.

Each way is valid. I think just need to declare given property may have different types before hit the validation.
And also it would be more readable.

Inheriting from Rateable thing sounds more like about contextual ontology to me.

from spira.

abrisse avatar abrisse commented on August 23, 2024

@cagdasolgun, the problem does not occur during the creation of a new Spira Resource, but when instanciating a Spira Resource using existing RDF statements. See build_value that use classize_resource (https://github.com/ruby-rdf/spira/blob/master/lib/spira/base.rb#L356).

from spira.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.