Module: Marley::Plugins::CurrentUserMethods::InstanceMethods

Defined in:
lib/marley/joints/user.rb

Instance Method Summary collapse

Instance Method Details

#after_initializeObject



36
37
38
39
# File 'lib/marley/joints/user.rb', line 36

def after_initialize
  super
  send("#{self.class.owner_col}=",$request[:user][:id]) if $request && self.class.owner_col && new?
end

#authorize(meth) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/marley/joints/user.rb', line 41

def authorize(meth)
  if respond_to?(auth_type="authorize_#{$request[:verb]}")
    send(auth_type,meth)
  else
    current_user_role && current_user_role != 'new'
  end
end

#current_user_roleObject



48
49
50
51
52
53
# File 'lib/marley/joints/user.rb', line 48

def current_user_role
  if u=self.class.current_user
    return 'new' if u.new?
    return "owner" if send_or_nil(self.class.owner_col)==u[:id]
  end
end

#requires_user?(verb = nil, meth = nil) ⇒ Boolean

Returns:

  • (Boolean)


40
# File 'lib/marley/joints/user.rb', line 40

def requires_user?(verb=nil,meth=nil);true;end