Sha256: 1a34fdfa968133605c90779947a76f6e7b6fef50b6db0e8d8b63bd166c5e2a36

Contents?: true

Size: 583 Bytes

Versions: 3

Compression:

Stored size: 583 Bytes

Contents

module PowerStencil
  module Utils

    module EntityHelper

      EntitySearchReference = Struct.new(:type, :name) do

        def self.from_string(string)
          if md = string.match(/^\s*(?<type>[^\/]+)\/\s*(?<name>.+)\s*$/)
            return new md[:type].to_sym, md[:name]
          end

          false
        end

        def as_path
          to_a.map(&:to_s).join '/'
        end

        def to_a
          [type, name]
        end

        def fill(something)
          something.type = type
          something.name = name
        end

      end


    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
power_stencil-0.10.0 lib/power_stencil/utils/entity_helper.rb
power_stencil-0.9.8 lib/power_stencil/utils/entity_helper.rb
power_stencil-0.9.7 lib/power_stencil/utils/entity_helper.rb