Sha256: 246ba5ae637f7029d5f4c2e539b660d5d38e7f12bbc8e7c0226d9bfd26db57f1
Contents?: true
Size: 814 Bytes
Versions: 71
Compression:
Stored size: 814 Bytes
Contents
module Coco module Concerns module HasName extend ActiveSupport::Concern def component_name @_component_name ||= self.class.send(:component_name) end class_methods do def component_name(name = nil) if name @_component_name = name.to_s.tr("_", "-") else @_component_name ||= [ component_group, component_path.demodulize.underscore.tr("_", "-") ].compact.uniq.join("-") end end protected def component_group @_component_group ||= component_path.split("::").first.underscore.tr("_", "-") end def component_path name.to_s.delete_suffix("Component").delete_prefix("Coco::") end end end end end
Version data entries
71 entries across 71 versions & 1 rubygems