christospappas / streama

Streama is a simple activity stream gem for use with the Mongoid ODM framework.
MIT License
132 stars 30 forks source link

Actor could be a polymorphic resource #11

Closed mulderp closed 12 years ago

mulderp commented 12 years ago

Hello,

I have been experimenting a bit more with the Streama code. For my current idea, I would need to work with an ActivityStream where an Actor would be a polymorphic resource, i.e. a user and a company could take part in the same activity definition.

For this, I have been experimenting with some small refactorings, as shown here: https://github.com/mulderp/streama/commits/actors I probably would introduce an Actor class that is embedded or referred to from an Activity.

Still some path to go, but eventually, feedback might be interesting, what you think on this.

mulderp commented 12 years ago

PS the background idea, is to have some kind of Activity Stream as in iTunes Ping, e.g. "Red Hot Chili Peppers released new album", "Flea released new solo album", etc. ... still experimenting...

christospappas commented 12 years ago

Hi Patrick,

Actor should already be polymorphic, you should be able to do this already by just defining two actors in the activity setup... eg.

activity :new_photo do
  actor :user, :cache => [:full_name]
  actor :company, :cache => [:name]
  object :photo, :cache => [:subject, :comment]
  target_object :album, :cache => [:title]
end

There is a spec in the definition_dsl_spec.rb file for this...

Is this what you mean?

mulderp commented 12 years ago

Great, now I get the idea in the DSL. I didn't realize the flexibility that the DSL gives.

Origin of my confusion was the exception that I got from InvalidData < StreamaError Exception.

Evt. the error messages could be extended, as in the case company is missing in the definition: "Invalid Data: company. Check DSL definition for Activity"