Module: Mayu::Resources::Types::Component::LoaderUtils

Extended by:
T::Sig
Defined in:
lib/mayu/resources/types/component.rb

Class Method Summary collapse

Class Method Details

.define_import(mod, resource) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mayu/resources/types/component.rb', line 16

def self.define_import(mod, resource)
  mod.instance_exec(resource) do |resource|
    define_singleton_method(:__resource) { resource }

    sig do
      params(path: String).returns(T.class_of(Mayu::Component::Base))
    end
    def self.import(path)
      __resource.import(path) => Component => impl
      impl.component
    end

    sig { params(path: String).returns(Image) }
    def self.image(path)
      __resource.import(path) => Image => impl
      impl
    end

    sig { params(path: String).returns(SVG) }
    def self.svg(path)
      __resource.import(path) => SVG => impl
      impl
    end
  end
end