Sha256: 61d82a24f33ea7e8cab912894537164288f5c57c07a5abeda8daa033f9c596b7
Contents?: true
Size: 989 Bytes
Versions: 2
Compression:
Stored size: 989 Bytes
Contents
require 'locabulary/items/base' require 'hanami/utils/string' module Locabulary # A container for the various types of Locabulary Items module Items module_function # @api public # @since 0.2.1 def build(options = {}) predicate_name = options.fetch(:predicate_name) { options.fetch('predicate_name') } builder_for(predicate_name: predicate_name).call(options) end # @api public # @since 0.2.1 # # @param options [Hash] # @option predicate_name [String] Used for lookup of the correct Locabulary::Item type def builder_for(options = {}) predicate_name = options.fetch(:predicate_name) possible_class_name_for_predicate_name = Hanami::Utils::String.new(predicate_name).singularize.classify klass = begin Items.const_get(possible_class_name_for_predicate_name) rescue NameError Items::Base end klass.method(:new) end end end require 'locabulary/items/administrative_unit'
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
locabulary-0.3.1 | lib/locabulary/items.rb |
locabulary-0.3.0 | lib/locabulary/items.rb |