Files
news.gitea.happylizard.me/bin/gems/facets-3.1.0/demo/standard/05_instantiable.rdoc
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

43 lines
561 B
Plaintext

= Instantiable
Require the library.
require 'facets/instantiable'
We will use this module as an example.
module M
include Instantiable
attr :a
def initialize(a)
@a = a
end
end
As we can see M is now fully instantiable, as any
class would be.
m = M.new(1)
m.a.assert == 1
We can also use #extend rather than #include and
get the same result.
module N
extend Instantiable
attr :a
def initialize( a )
@a = a
end
end
As we saw with +M+ so too with +N+.
n = N.new( 1 )
n.a.assert == 1