Class: Clowne::Declarations::Trait

Inherits:
Object
  • Object
show all
Defined in:
lib/clowne/declarations/trait.rb

Overview

:nodoc: all

Instance Method Summary collapse

Constructor Details

#initializeTrait

Returns a new instance of Trait.



6
7
8
# File 'lib/clowne/declarations/trait.rb', line 6

def initialize
  @blocks = []
end

Instance Method Details

#compiledObject Also known as: declarations



14
15
16
17
18
# File 'lib/clowne/declarations/trait.rb', line 14

def compiled
  return @compiled if instance_variable_defined?(:@compiled)

  @compiled = compile
end

#dupObject



22
23
24
25
26
# File 'lib/clowne/declarations/trait.rb', line 22

def dup
  self.class.new.tap do |duped|
    blocks.each { |b| duped.extend_with(b) }
  end
end

#extend_with(block) ⇒ Object



10
11
12
# File 'lib/clowne/declarations/trait.rb', line 10

def extend_with(block)
  @blocks << block
end