Module: Extensions::Conditional::ActiveRecord::Base::ConditionInstanceMethods

Extended by:
ActiveSupport::Concern
Defined in:
lib/extensions/conditional/active_record/base.rb

Instance Method Summary collapse

Instance Method Details

#dependent_objectObject

Returns Conditional object that the condition depends on to check if it is satisfiable

Returns:

  • (Object)

    Conditional object that the condition depends on to check if it is satisfiable

Raises:

  • (NotImplementedError)

82
83
84
# File 'lib/extensions/conditional/active_record/base.rb', line 82

def dependent_object
  raise NotImplementedError, 'Subclasses must implement a dependent_object method.'
end

#satisfied_by?(_user) ⇒ Boolean

Checks if the condition is satisfied by the user.

Parameters:

  • _user (CourseUser)

    The user that the condition is being checked on

Returns:

  • (Boolean)

    true if the condition is met and false otherwise

Raises:

  • (NotImplementedError)

90
91
92
# File 'lib/extensions/conditional/active_record/base.rb', line 90

def satisfied_by?(_user)
  raise NotImplementedError, 'Subclasses must implement a satisfied_by? method.'
end

#titleObject

A human-readable name for each condition; usually just wraps a title or name field. Meant to be used in a polymorphic manner for views.

Raises:

  • (NotImplementedError)

76
77
78
# File 'lib/extensions/conditional/active_record/base.rb', line 76

def title
  raise NotImplementedError, 'Subclasses must implement a title method.'
end