Class: Accord::Declarations::Implements
- Inherits:
-
Declaration
- Object
- Specification
- Declaration
- Accord::Declarations::Implements
- Defined in:
- lib/accord/declarations.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #declare(*interfaces) ⇒ Object
- #declare_only(*interfaces) ⇒ Object
-
#initialize(inherit) ⇒ Implements
constructor
A new instance of Implements.
- #inspect ⇒ Object
Methods inherited from Declaration
Methods inherited from Specification
#ancestors, #bases, #bases=, #each_interface, #extends?, #interfaces
Constructor Details
#initialize(inherit) ⇒ Implements
Returns a new instance of Implements.
24 25 26 27 28 29 |
# File 'lib/accord/declarations.rb', line 24 def initialize(inherit) @inherit = inherit set_name(inherit) @declared = [] super(bases_from_inherit) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
22 23 24 |
# File 'lib/accord/declarations.rb', line 22 def name @name end |
Instance Method Details
#declare(*interfaces) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/accord/declarations.rb', line 31 def declare(*interfaces) @declared.concat(normalized(interfaces)).uniq! new_bases = @declared.dup bases_from_inherit.each do |base| new_bases << base if !@declared.include?(base) end self.bases = new_bases end |
#declare_only(*interfaces) ⇒ Object
40 41 42 43 44 |
# File 'lib/accord/declarations.rb', line 40 def declare_only(*interfaces) @declared = [] self.inherit = nil declare(*interfaces) end |
#inspect ⇒ Object
46 47 48 |
# File 'lib/accord/declarations.rb', line 46 def inspect "#<Implemented by #{name}>" end |