Module: WebFunction::Flaggable

Included in:
Argument, Attribute, Endpoint, Package
Defined in:
lib/web_function/flaggable.rb

Overview

A module that provides a flaggable interface. Flags are used to define the behavior of an object.

Examples:

class Endpoint
  include Flaggable

  def initialize(name:, flags: [])
    @name = name
    @flags = flags
  end
end

endpoint = Endpoint.new(name: "get_user", flags: ["private"])
endpoint.flag?("private") # => true
endpoint.flag?("public") # => false

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#flagsArray<String> (readonly)

List of flags. See the [available flags section] on the Web Function website for a complete list of flags available.

[2]: webfunction.org/package#available-flags

Returns:

  • (Array<String>)


28
29
30
# File 'lib/web_function/flaggable.rb', line 28

def flags
  @flags
end

Instance Method Details

#flag?(flag) ⇒ Boolean

Whether the endpoint declares the given flag.

Parameters:

  • flag (String)

    The flag to check for.

Returns:

  • (Boolean)


36
37
38
# File 'lib/web_function/flaggable.rb', line 36

def flag?(flag)
  @flags.include?(flag)
end