Class: ActiveEntry::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/active_entry/base.rb

Direct Known Subclasses

Authentication, Authorization

Defined Under Namespace

Classes: Authentication, Authorization

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method_name, **args) ⇒ Base

Returns a new instance of Base.



27
28
29
30
31
# File 'lib/active_entry/base.rb', line 27

def initialize method_name, **args
  @_method_name_to_entrify = method_name
  @_args = args
  @_args.each { |name, value| instance_variable_set ["@", name].join, value }
end

Class Method Details

.pass!(method_name, **args) ⇒ Object



34
35
36
37
# File 'lib/active_entry/base.rb', line 34

def pass! method_name, **args
  Authentication.pass! method_name, **args
  Authorization.pass! method_name, **args
end

.pass?(method_name, **args) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
42
# File 'lib/active_entry/base.rb', line 39

def pass? method_name, **args
  Authentication.pass? method_name, **args
  Authorization.pass? method_name, **args
end

Instance Method Details

#pass!Object



46
47
48
# File 'lib/active_entry/base.rb', line 46

def pass!
  pass? or raise self.class::AUTH_ERROR.new(@error, @_method_name_to_entrify, @_args)
end

#pass?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/active_entry/base.rb', line 50

def pass?
  decision_maker_method.call == true
end

#successObject



54
55
56
# File 'lib/active_entry/base.rb', line 54

def success
  true
end