Sha256: e57b756790bd72fb0251b865265c3db06fd00ee8543eb568228c054115eebcd4
Contents?: true
Size: 830 Bytes
Versions: 2
Compression:
Stored size: 830 Bytes
Contents
module Wallaby::Utils def self.to_resources_name(model_class) return '' if model_class.blank? model_class.to_s.underscore.gsub('/', '::').pluralize end def self.to_model_label(model_class) model_class_name = to_model_name model_class model_class_name.titleize.gsub '/', ' / ' end def self.to_model_name(resources_name) return '' if resources_name.blank? resources_name.to_s.singularize.gsub('::', '/').camelize end def self.to_model_class(resources_name, source = nil) return if resources_name.blank? begin class_name = to_model_name resources_name class_name.constantize rescue message = [ class_name, source ].compact.join(' from ') fail Wallaby::ModelNotFound, message end end def self.to_hash(array) Hash[ *array.flatten(1) ] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wallaby-4.1.6 | lib/utils/wallaby/utils.rb |
wallaby-5.0.1 | lib/utils/wallaby/utils.rb |