Module: LookupBy

Defined in:
lib/lookup_by/association.rb,
lib/lookup_by.rb,
lib/lookup_by/cache.rb,
lib/lookup_by/lookup.rb,
lib/lookup_by/railtie.rb,
lib/lookup_by/version.rb,
lib/lookup_by/caching/lru.rb,
lib/lookup_by/hooks/cucumber.rb,
lib/lookup_by/caching/safe_lru.rb,
lib/lookup_by/hooks/formtastic.rb,
lib/lookup_by/hooks/simple_form.rb,
lib/lookup_by/caching/lru_legacy.rb

Overview

TODO: play nicely with belongs_to TODO: has_many association

class Decision lookup_for :reasons end

Decision.first.reasons => ["employment", "income"]

Decision.new.reasons = %w(employment income)

Defined Under Namespace

Modules: Association, Caching, Hooks, Lookup Classes: Cache, Error, Railtie, RecordNotFound

Constant Summary collapse

UUID_REGEX =
/\A\h{8}-\h{4}-\h{4}-\h{4}-\h{12}\Z/
UUID_REGEX_V4 =
/\A\h{8}-\h{4}-4\h{3}-[89aAbB]\h{3}-\h{12}\Z/
VERSION =
"0.10.8"

Class Method Summary collapse

Class Method Details

.clearObject



37
38
39
# File 'lib/lookup_by.rb', line 37

def clear
  lookups.each { |lookup| lookup.clear }
end

.disableObject



41
42
43
# File 'lib/lookup_by.rb', line 41

def disable
  lookups.each { |lookup| lookup.disable! }
end

.enableObject



45
46
47
# File 'lib/lookup_by.rb', line 45

def enable
  lookups.each { |lookup| lookup.enable! }
end

.lookupsObject



33
34
35
# File 'lib/lookup_by.rb', line 33

def lookups
  classes.map { |klass| klass.lookup }
end

.register(klass) ⇒ Object



27
28
29
30
31
# File 'lib/lookup_by.rb', line 27

def register(klass)
  mutex.synchronize do
    self.classes << klass unless classes.include?(klass)
  end
end

.reloadObject



49
50
51
# File 'lib/lookup_by.rb', line 49

def reload
  lookups.each { |lookup| lookup.reload }
end