Class: PostActionType

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AnonCacheInvalidator
Defined in:
app/models/post_action_type.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.flag_settingsObject (readonly)

Returns the value of attribute flag_settings.



15
16
17
# File 'app/models/post_action_type.rb', line 15

def flag_settings
  @flag_settings
end

Class Method Details

.auto_action_flag_typesObject



41
42
43
# File 'app/models/post_action_type.rb', line 41

def auto_action_flag_types
  flag_settings.auto_action_types
end

.custom_typesObject



74
75
76
# File 'app/models/post_action_type.rb', line 74

def custom_types
  flag_settings.custom_types
end

.flag_typesObject



57
58
59
# File 'app/models/post_action_type.rb', line 57

def flag_types
  flag_settings.flag_types
end

.flag_types_without_customObject



53
54
55
# File 'app/models/post_action_type.rb', line 53

def flag_types_without_custom
  flag_settings.without_custom_types
end

.is_flag?(sym) ⇒ Boolean

Returns:

  • (Boolean)


78
79
80
# File 'app/models/post_action_type.rb', line 78

def is_flag?(sym)
  flag_types.valid?(sym)
end

.notify_flag_type_idsObject

flags resulting in mod notifications



62
63
64
# File 'app/models/post_action_type.rb', line 62

def notify_flag_type_ids
  notify_flag_types.values
end

.notify_flag_typesObject



66
67
68
# File 'app/models/post_action_type.rb', line 66

def notify_flag_types
  flag_settings.notify_types
end

.orderedObject



26
27
28
# File 'app/models/post_action_type.rb', line 26

def ordered
  order("position asc")
end

.public_type_idsObject



49
50
51
# File 'app/models/post_action_type.rb', line 49

def public_type_ids
  @public_type_ids ||= public_types.values
end

.public_typesObject



45
46
47
# File 'app/models/post_action_type.rb', line 45

def public_types
  @public_types ||= types.except(*flag_types.keys << :notify_user)
end

.replace_flag_settings(settings) ⇒ Object



17
18
19
20
21
22
23
24
# File 'app/models/post_action_type.rb', line 17

def replace_flag_settings(settings)
  if settings
    @flag_settings = settings
  else
    initialize_flag_settings
  end
  @types = nil
end

.topic_flag_typesObject



70
71
72
# File 'app/models/post_action_type.rb', line 70

def topic_flag_types
  flag_settings.topic_flag_types
end

.typesObject



30
31
32
33
34
35
36
37
38
39
# File 'app/models/post_action_type.rb', line 30

def types
  unless @types
    # NOTE: Previously bookmark was type 1 but that has been superseded
    # by the separate Bookmark model and functionality
    @types = Enum.new(like: 2)
    @types.merge!(flag_settings.flag_types)
  end

  @types
end

Instance Method Details

#expire_cacheObject



9
10
11
12
# File 'app/models/post_action_type.rb', line 9

def expire_cache
  ApplicationSerializer.expire_cache_fragment!(/\Apost_action_types_/)
  ApplicationSerializer.expire_cache_fragment!(/\Apost_action_flag_types_/)
end