Module: Platanus::Canned::ProfileManager::ClassMethods

Defined in:
lib/platanus/canned.rb

Instance Method Summary collapse

Instance Method Details

#can?(_profile, _action, _action_feat, _user_feat) ⇒ Boolean

Test if a user (profile + user data) can execute a given action (action name + action data).



223
224
225
226
227
# File 'lib/platanus/canned.rb', line 223

def can?(_profile, _action, _action_feat, _user_feat)
  profile = self.profiles[_profile.to_s]
  return false if profile.nil?
  return profile.test(_action, _action_feat, _user_feat)
end

#profile(_name, _options = {}) {|self.profiles[_name.to_s] = BProfile.new( self, self.profiles[_options.fetch(:inherits, nil)], _options.fetch(:default, :equals) )| ... } ⇒ Object

Creates a new profile and passes it to the given block. This can optionally take an inherit parameter to use another profile as base for the new one.

Yields:

  • (self.profiles[_name.to_s] = BProfile.new( self, self.profiles[_options.fetch(:inherits, nil)], _options.fetch(:default, :equals) ))


213
214
215
216
217
218
219
# File 'lib/platanus/canned.rb', line 213

def profile(_name, _options={})
  yield self.profiles[_name.to_s] = BProfile.new(
    self,
    self.profiles[_options.fetch(:inherits, nil)],
    _options.fetch(:default, :equals)
  )
end