Class: SemgrepWebApp::Visibility

Inherits:
Object
  • Object
show all
Defined in:
lib/semgrep_web_app/models/visibility.rb

Overview

Repository visbility (e.g. public, private, unknown). | value | description | |-------|---------------| | REPOSITORY_VISIBILITY_PUBLIC | | | REPOSITORY_VISIBILITY_PRIVATE | | | REPOSITORY_VISIBILITY_UNKNOWN | |

Constant Summary collapse

VISIBILITY =
[
  # TODO: Write general description for REPOSITORY_VISIBILITY_PUBLIC
  REPOSITORY_VISIBILITY_PUBLIC = 'REPOSITORY_VISIBILITY_PUBLIC'.freeze,

  # TODO: Write general description for REPOSITORY_VISIBILITY_PRIVATE
  REPOSITORY_VISIBILITY_PRIVATE = 'REPOSITORY_VISIBILITY_PRIVATE'.freeze,

  # TODO: Write general description for REPOSITORY_VISIBILITY_UNKNOWN
  REPOSITORY_VISIBILITY_UNKNOWN = 'REPOSITORY_VISIBILITY_UNKNOWN'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = REPOSITORY_VISIBILITY_PUBLIC) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/semgrep_web_app/models/visibility.rb', line 28

def self.from_value(value, default_value = REPOSITORY_VISIBILITY_PUBLIC)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'repository_visibility_public' then REPOSITORY_VISIBILITY_PUBLIC
  when 'repository_visibility_private' then REPOSITORY_VISIBILITY_PRIVATE
  when 'repository_visibility_unknown' then REPOSITORY_VISIBILITY_UNKNOWN
  else
    default_value
  end
end

.validate(value) ⇒ Object



22
23
24
25
26
# File 'lib/semgrep_web_app/models/visibility.rb', line 22

def self.validate(value)
  return false if value.nil?

  VISIBILITY.include?(value)
end