I have planned about 15 models or so, and as part of my learning Hobo, it seems
necessary to define the 4 permission methods in each model. Eg.
<code><pre>
class MyModel42 < ActiveRecord::Base
def create_permitted?
acting_user.signed_up?
end
def update_permitted?
acting_user.administrator? || owner_is?(acting_user)
end
def destroy_permitted?
acting_user.administrator? || owner_is?(acting_user)
end
def view_permitted?(field)
true
end
</pre></code>
Since most of the models will use the same permissions, it should be simple to
have them inherit the "standard" permission methods. Where are these defined?
Should I use a class hierarchy? Eg:
<code><pre>
class StandardAppModel < ActiveRecord::Base
hobo_model
def create_permitted?
acting_user.signed_up?
end
def update_permitted?
acting_user.administrator? || owner_is?(acting_user)
end
def destroy_permitted?
acting_user.administrator? || owner_is?(acting_user)
end
def view_permitted?(field)
true
end
end
class MyModel42 < StandardAppModel
…
end
</pre></code>
What is not clear is if the abstract class "StandardAppModel" should have the
"hobo_model" invocation, or if that should be done within the sub-classes?
<code><pre>
class MyModel42 < StandardAppModel
hobo_model
…
end
</pre></code>
OR, should I use a module to define the permission methods, and include that
module into each model?
<code><pre>
module StandardPermissions
def create_permitted?
…
end
def update_permitted?
…
end
…
end
class MyModel42 < ActiveRecord::Base
hobo_model
...
include StandardPermissions
end
</pre></code>
Thanks for any helpful answers.
--
Alan
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.