Sha256: 7214e4bb99b6dd4d9891ff3ff31ef2214910468c0ef5d5aef541df692d3f61af

Contents?: true

Size: 598 Bytes

Versions: 7

Compression:

Stored size: 598 Bytes

Contents

# frozen_string_literal: true

module ::AmberComponent
  module Helpers
    # Adds class-specific utilities.
    module ClassHelper
      # Name of the constant this class/module is saved in (in the parent module).
      #
      # @return [String]
      def const_name
        name.split('::').last
      end

      # Get the exact place where this class/module has been defined.
      #
      # @return [Array(String, Integer), Array(Boolean, Integer)] File path followed by line number.
      def source_location
        module_parent.const_source_location const_name
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
amber_component-1.2.0 lib/amber_component/helpers/class_helper.rb
amber_component-1.1.1 lib/amber_component/helpers/class_helper.rb
amber_component-1.1.0 lib/amber_component/helpers/class_helper.rb
amber_component-1.0.0 lib/amber_component/helpers/class_helper.rb
amber_component-0.0.5 lib/amber_component/helpers/class_helper.rb
amber_component-0.0.4 lib/amber_component/helpers/class_helper.rb
amber_component-0.0.3 lib/amber_component/helpers/class_helper.rb