Class: Annotate::Helpers

Inherits:
Object
  • Object
show all
Defined in:
lib/annotate/helpers.rb

Overview

Class for holding helper methods. Done to make lib/annotate.rb less bloated.

Class Method Summary collapse

Class Method Details

.fallback(*args) ⇒ Object



24
25
26
# File 'lib/annotate/helpers.rb', line 24

def fallback(*args)
  args.detect(&:present?)
end

.include_models?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/annotate/helpers.rb', line 16

def include_models?
  ENV.fetch('models', nil) =~ Constants::TRUE_RE
end

.include_routes?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/annotate/helpers.rb', line 12

def include_routes?
  ENV.fetch('routes', nil) =~ Constants::TRUE_RE
end

.reset_options(options) ⇒ Object



28
29
30
# File 'lib/annotate/helpers.rb', line 28

def reset_options(options)
  options.flatten.each { |key| ENV[key.to_s] = nil }
end

.skip_on_migration?Boolean

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/annotate/helpers.rb', line 7

def skip_on_migration?
  ENV.fetch('ANNOTATE_SKIP_ON_DB_MIGRATE',
            nil) =~ Constants::TRUE_RE || ENV.fetch('skip_on_db_migrate', nil) =~ Constants::TRUE_RE
end

.true?(val) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/annotate/helpers.rb', line 20

def true?(val)
  val.present? && Constants::TRUE_RE.match?(val)
end