Module: Ooor::OoorBehavior::ClassMethods

Defined in:
lib/ooor.rb

Constant Summary collapse

IRREGULAR_CONTEXT_POSITIONS =
{
  import_data: 5,
  fields_view_get: 2,
  search: 4,
  name_search:  3,
  read_group: 5,
  fields_get: 1,
  read: 2,
  perm_read: 1,
  check_recursion: 1
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cache_storeObject

Returns the value of attribute cache_store.



46
47
48
# File 'lib/ooor.rb', line 46

def cache_store
  @cache_store
end

#default_configObject

Returns the value of attribute default_config.



46
47
48
# File 'lib/ooor.rb', line 46

def default_config
  @default_config
end

#default_sessionObject

Returns the value of attribute default_session.



46
47
48
# File 'lib/ooor.rb', line 46

def default_session
  @default_session
end

Instance Method Details

#cache(store = nil) ⇒ Object



69
70
71
# File 'lib/ooor.rb', line 69

def cache(store=nil)
  @cache_store ||= ActiveSupport::Cache.lookup_store(store)
end

#extensionsObject



80
81
82
# File 'lib/ooor.rb', line 80

def extensions
  @extensions ||= {}
end

#irregular_context_position(method) ⇒ Object



95
96
97
# File 'lib/ooor.rb', line 95

def irregular_context_position(method)
  IRREGULAR_CONTEXT_POSITIONS.merge(default_config[:irregular_context_positions] || {})[method.to_sym]
end

#loggerObject



87
88
89
# File 'lib/ooor.rb', line 87

def logger
  @logger ||= Logger.new($stdout)
end

#logger=(logger) ⇒ Object



91
92
93
# File 'lib/ooor.rb', line 91

def logger=(logger)
  @logger = logger
end

#model_registryObject



85
# File 'lib/ooor.rb', line 85

def model_registry() @model_registry ||= ModelRegistry.new; end

#new(config = {}) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/ooor.rb', line 60

def new(config={})
  Ooor.default_config = config.merge(generate_constants: true)
  session = session_handler.retrieve_session(config)
  if config[:database] && config[:password]
    session.(config)
  end
  Ooor.default_session = session
end

#session_handlerObject



84
# File 'lib/ooor.rb', line 84

def session_handler() @session_handler ||= SessionHandler.new; end

#xtend(model_name, &block) ⇒ Object



73
74
75
76
77
78
# File 'lib/ooor.rb', line 73

def xtend(model_name, &block)
  @extensions ||= {}
  @extensions[model_name] ||= []
  @extensions[model_name] << block
  @extensions
end