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



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

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

.include_models?Boolean



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

def include_models?
  ENV['models'] =~ Constants::TRUE_RE
end

.include_routes?Boolean



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

def include_routes?
  ENV['routes'] =~ Constants::TRUE_RE
end

.reset_options(options) ⇒ Object



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

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

.skip_on_migration?Boolean



5
6
7
# File 'lib/annotate/helpers.rb', line 5

def skip_on_migration?
  ENV['ANNOTATE_SKIP_ON_DB_MIGRATE'] =~ Constants::TRUE_RE || ENV['skip_on_db_migrate'] =~ Constants::TRUE_RE
end

.true?(val) ⇒ Boolean



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

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