Sha256: 061b3fc4351b784e6a43d3e644a89e98875d76714b757bf83dac8f1b5df2c09f
Contents?: true
Size: 859 Bytes
Versions: 4
Compression:
Stored size: 859 Bytes
Contents
# frozen_string_literal: true module Clowne module Declarations class Trait # :nodoc: all def initialize @blocks = [] end def extend_with(block) @blocks << block end def compiled return @compiled if instance_variable_defined?(:@compiled) @compiled = compile end alias declarations compiled def dup self.class.new.tap do |duped| blocks.each { |b| duped.extend_with(b) } end end private attr_reader :blocks def compile anonymous_cloner = Class.new(Clowne::Cloner) blocks.each do |block| anonymous_cloner.instance_eval(&block) end anonymous_cloner.declarations end end end end Clowne::Declarations.add :trait do |name, &block| register_trait name, block end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
clowne-1.3.0 | lib/clowne/declarations/trait.rb |
clowne-1.2.0 | lib/clowne/declarations/trait.rb |
clowne-1.1.0 | lib/clowne/declarations/trait.rb |
clowne-1.0.0 | lib/clowne/declarations/trait.rb |