Hi,

view_permitted is a normal ruby method, which has access to all of its other methods in the object, including the "state" variable (you need to drop the leading ":" in your example).

You are on the right track. The example you gave (modulo syntax errors) follows a common pattern.

Henry

On 20/07/15 11:13 AM, Nathan Peters wrote:
Thank you for the info and examples. That clarifies how Hobo does things. In particular I have a better grasp of how lifecycles and instance methods are handled.

With view_permitted?, can I reference a field name and also another field in the same record? So if, for example, I have a 'user' object that has a tasker boolean and a 'project' that has a review text and lifecycle state that I am checking is "Finished". I only want the tasker to see the review field when the lifecycle state is "Finished" So:

def view_permitted?(field)
     acting_user.administrator? ||
     (field == :review && acting_user.tasker? && :state == "Finished")
end

I realize that the ':state == "Finished"' syntax is probably bad. But maybe you can see what I'm getting at: I want to be able to reference the :state field in the same record to determine visibility of the :review field. I imagine this is possible but it may not work the way I think, or there may be a better way to define that type of permission.

Thanks

On Mon, Jul 20, 2015 at 8:54 AM, Henry Baragar <[email protected] <mailto:[email protected]>> wrote:

    Hi,

    The nice thing about hobo is that it is easy to test complex
    permission situations through your model tests. take a look at
    https://groups.google.com/d/msg/hobousers/XMpolsF5Ty8/63wLKVw-5mwJ
    for how I do it.

    Regards,
    Henry

    On 17/07/15 12:05 PM, Nathan Peters wrote:
    I'm starting a new Hobo project that is going to have a very
    complicated (to my experience) permission structure. It is a
    process control app. Visibility on some things will be controlled
    both by date and by active user. Users will not even be able to
    see certain things until a target date, at which point they will
    have edit rights which should be removed after a second target
    date. In short, it is heady stuff.

    Any tips as I delve into this type of thing? Are there some
    examples out there (on GitHub or other) that would be a good
    reference as I think about more complicated process permissions
    in Hobo?

    Thanks,
    Nathan
-- You received this message because you are subscribed to the
    Google Groups "Hobo Users" group.
    To unsubscribe from this group and stop receiving emails from it,
    send an email to [email protected]
    <mailto:[email protected]>.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    Visit this group at http://groups.google.com/group/hobousers.
    For more options, visit https://groups.google.com/d/optout.

-- Henry Baragar
    Instantiated Software Inc.
    http://www.instantiated.ca

-- You received this message because you are subscribed to a topic in
    the Google Groups "Hobo Users" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/hobousers/JBnhy9Oau4s/unsubscribe.
    To unsubscribe from this group and all its topics, send an email
    to [email protected]
    <mailto:[email protected]>.
    To post to this group, send email to [email protected]
    <mailto:[email protected]>.
    Visit this group at http://groups.google.com/group/hobousers.
    For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Hobo Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>.
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.

--
Henry Baragar
Instantiated Software Inc.
http://www.instantiated.ca

--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/hobousers.
For more options, visit https://groups.google.com/d/optout.

<<attachment: Henry_Baragar.vcf>>

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to