Module: Flexite

Extended by:
ActiveSupport::Autoload
Defined in:
lib/flexite.rb,
lib/flexite/flexy.rb,
lib/flexite/engine.rb,
lib/flexite/version.rb,
lib/flexite/nodes_hash.rb,
app/models/flexite/diff.rb,
lib/flexite/cached_node.rb,
app/models/flexite/entry.rb,
app/models/flexite/config.rb,
lib/flexite/configuration.rb,
app/models/flexite/history.rb,
app/forms/flexite/entry/form.rb,
app/models/flexite/arr_entry.rb,
app/forms/flexite/config/form.rb,
app/models/flexite/bool_entry.rb,
app/models/flexite/job_report.rb,
app/services/flexite/diff/token.rb,
app/forms/flexite/entry/array_form.rb,
app/helpers/flexite/configs_helper.rb,
app/helpers/flexite/entries_helper.rb,
app/models/flexite/history_attribute.rb,
app/factories/flexite/service_factory.rb,
app/presenters/flexite/diff_presenter.rb,
app/services/flexite/data/new_service.rb,
app/services/flexite/diff/get_service.rb,
app/controllers/flexite/api_controller.rb,
app/helpers/flexite/application_helper.rb,
app/services/flexite/diff/push_service.rb,
app/services/flexite/diff/show_service.rb,
app/services/flexite/diff/apply_service.rb,
app/services/flexite/diff/check_service.rb,
app/controllers/flexite/diffs_controller.rb,
app/models/concerns/flexite/with_history.rb,
app/services/flexite/data/migrators/yaml.rb,
app/services/flexite/entry/create_service.rb,
app/services/flexite/entry/update_service.rb,
app/controllers/flexite/configs_controller.rb,
app/controllers/flexite/entries_controller.rb,
app/services/flexite/config/create_service.rb,
app/services/flexite/config/update_service.rb,
app/services/flexite/entry/destroy_service.rb,
app/services/flexite/diff/save_diff_service.rb,
app/controllers/flexite/histories_controller.rb,
app/services/flexite/entry/inner_processable.rb,
app/controllers/flexite/application_controller.rb,
app/services/flexite/entry/array_create_service.rb,
app/services/flexite/entry/array_update_service.rb,
app/services/flexite/entry/destroy_array_entry_service.rb

Defined Under Namespace

Modules: ApplicationHelper, ConfigsHelper, Data, EntriesHelper, WithHistory Classes: ActionService, ApiController, ApplicationController, ArrEntry, BaseFactory, BaseForm, BoolEntry, CachedNode, Config, ConfigsController, Configuration, Diff, DiffPresenter, DiffsController, Engine, EntriesController, Entry, Flexy, HistoriesController, History, HistoryAttribute, IntEntry, JobReport, NodesHash, ServiceFactory, StrEntry, SymEntry

Constant Summary collapse

VERSION =
'0.0.25'
@@config =
Configuration.new

Class Method Summary collapse

Class Method Details

.cacheObject



26
27
28
# File 'lib/flexite.rb', line 26

def cache
  @@config.cache
end

.cached_nodesObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/flexite.rb', line 43

def cached_nodes
  return unless Config.table_exists?

  cache.fetch(@@config.root_cache_key) do
    Config.where(config_id: nil).each_with_object(NodesHash.new) do |root, memo|
      memo[root.name] = cache.fetch(root) do
        CachedNode.new(root)
      end
    end
  end
end

.configure {|@@config| ... } ⇒ Object

Yields:

  • (@@config)


22
23
24
# File 'lib/flexite.rb', line 22

def configure
  yield(@@config)
end

.match_key(pattern) ⇒ Object



39
40
41
# File 'lib/flexite.rb', line 39

def match_key(pattern)
  @@config.cache_matcher.call(pattern)
end

.reload_root_cacheObject



30
31
32
33
# File 'lib/flexite.rb', line 30

def reload_root_cache
  cache.clear
  cached_nodes
end

.state_digestObject



35
36
37
# File 'lib/flexite.rb', line 35

def state_digest
  Digest::MD5.hexdigest("#{Config.maximum(:updated_at)}#{Entry.maximum(:updated_at)}#{Config.count}#{Entry.count}")
end