Module: Appfuel::Repository
- Defined in:
- lib/appfuel/storage/repository/runner.rb,
lib/appfuel/storage/repository.rb,
lib/appfuel/storage/repository/base.rb,
lib/appfuel/storage/repository/expr.rb,
lib/appfuel/storage/repository/mapper.rb,
lib/appfuel/storage/repository/criteria.rb,
lib/appfuel/storage/repository/settings.rb,
lib/appfuel/storage/repository/order_expr.rb,
lib/appfuel/storage/repository/expr_parser.rb,
lib/appfuel/storage/repository/initializer.rb,
lib/appfuel/storage/repository/mapping_dsl.rb,
lib/appfuel/storage/repository/mapping_entry.rb,
lib/appfuel/storage/repository/search_parser.rb,
lib/appfuel/storage/repository/expr_transform.rb,
lib/appfuel/storage/repository/expr_conjunction.rb,
lib/appfuel/storage/repository/search_transform.rb
Overview
Used in the validation system by custom predicates to ask the question if an entity exists in the database
Defined Under Namespace
Classes: Base, Criteria, Expr, ExprConjunction, ExprParser, ExprTransform, Initializer, Mapper, MappingDsl, MappingEntry, OrderExpr, Runner, SearchParser, SearchTransform, Settings
Class Method Summary collapse
- .create_builder(repo, &block) ⇒ Object
- .create_repo(type, domain_name) ⇒ Object
- .entity_builder(domain_name, type, opts = {}, &block) ⇒ Object
-
.mapping(domain_name, options = {}, &block) ⇒ DbEntityMapper
Mapping uses the map_dsl_class to define and map mapping entries into the mapping registry.
Class Method Details
.create_builder(repo, &block) ⇒ Object
79 80 81 82 83 |
# File 'lib/appfuel/storage/repository.rb', line 79 def self.create_builder(repo, &block) ->(storage, criteria) { repo.instance_exec(storage, criteria, &block) } end |
.create_repo(type, domain_name) ⇒ Object
71 72 73 74 75 76 77 |
# File 'lib/appfuel/storage/repository.rb', line 71 def self.create_repo(type, domain_name) repo_class = "Appfuel::#{type.to_s.classify}::Repository" unless Kernel.const_defined?(repo_class) fail "Could not find #{repo_class} for entity builder #{domain_name}" end Kernel.const_get(repo_class).new end |
.entity_builder(domain_name, type, opts = {}, &block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/appfuel/storage/repository.rb', line 58 def self.entity_builder(domain_name, type, opts = {}, &block) fail "entity builder must be used with a block" unless block_given? root = opts[:root] || Appfuel.default_app_name repo = create_repo(type, domain_name) repo.class.load_path_from_container_namespace("#{root}.#{domain_name}") app_container = Appfuel.app_container(root) category = "domain_builders.#{type}" builder_key = repo.qualify_container_key(domain_name, category) app_container.register(builder_key, create_builder(repo, &block)) end |
.mapping(domain_name, options = {}, &block) ⇒ DbEntityMapper
Mapping uses the map_dsl_class to define and map mapping entries into the mapping registry
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/appfuel/storage/repository.rb', line 41 def self.mapping(domain_name, = {}, &block) dsl = MappingDsl.new(domain_name, ) dsl.instance_eval(&block) dsl.entries.each do |entry| root = entry.container_name || Appfuel.default_app_name container = Appfuel.app_container(root) mappings = container['repository_mappings'] domain_name = entry.domain_name mappings[domain_name] = {} unless mappings.key?(domain_name) entries = mappings[domain_name] entries[entry.domain_attr] = entry end end |