Class: ArchSpec::DSL::ComponentProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/archspec/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(definition, name) ⇒ ComponentProxy

Returns a new instance of ComponentProxy.



68
69
70
71
# File 'lib/archspec/dsl.rb', line 68

def initialize(definition, name)
  @definition = definition
  @name = name.to_sym
end

Instance Attribute Details

#definitionObject (readonly)

Returns the value of attribute definition.



66
67
68
# File 'lib/archspec/dsl.rb', line 66

def definition
  @definition
end

#nameObject (readonly)

Returns the value of attribute name.



66
67
68
# File 'lib/archspec/dsl.rb', line 66

def name
  @name
end

Instance Method Details

#can_use(*targets) ⇒ Object Also known as: only_depend_on, must_only_depend_on



73
74
75
76
# File 'lib/archspec/dsl.rb', line 73

def can_use(*targets)
  add_rule(Rules::AllowDependenciesRule.new(name, targets))
  self
end

#cannot_call(*methods) ⇒ Object



86
87
88
89
# File 'lib/archspec/dsl.rb', line 86

def cannot_call(*methods)
  add_rule(Rules::CannotCallRule.new(name, methods))
  self
end

#cannot_define(*methods) ⇒ Object



91
92
93
94
# File 'lib/archspec/dsl.rb', line 91

def cannot_define(*methods)
  add_rule(Rules::CannotDefineMethodRule.new(name, methods))
  self
end

#cannot_instantiate_and_invokeObject



96
97
98
99
# File 'lib/archspec/dsl.rb', line 96

def cannot_instantiate_and_invoke
  add_rule(Rules::CannotInstantiateAndInvokeRule.new(name))
  self
end

#cannot_reference_constants(*constants) ⇒ Object



101
102
103
104
# File 'lib/archspec/dsl.rb', line 101

def cannot_reference_constants(*constants)
  add_rule(Rules::CannotReferenceConstantsRule.new(name, constants))
  self
end

#cannot_use(*targets) ⇒ Object



81
82
83
84
# File 'lib/archspec/dsl.rb', line 81

def cannot_use(*targets)
  add_rule(Rules::ForbidDependenciesRule.new(name, targets))
  self
end

#must_be_empty(because: nil) ⇒ Object



106
107
108
109
# File 'lib/archspec/dsl.rb', line 106

def must_be_empty(because: nil)
  add_rule(Rules::MustBeEmptyRule.new(name, because: because))
  self
end

#must_implement(*methods) ⇒ Object



111
112
113
114
115
116
# File 'lib/archspec/dsl.rb', line 111

def must_implement(*methods)
  methods.each do |method_name|
    add_rule(Rules::MustImplementRule.new(name, method_name))
  end
  self
end

#must_implement_one_of(*methods) ⇒ Object



118
119
120
121
# File 'lib/archspec/dsl.rb', line 118

def must_implement_one_of(*methods)
  add_rule(Rules::MustImplementOneOfRule.new(name, methods))
  self
end