Class: Bparity::Boundary::Subject

Inherits:
Struct
  • Object
show all
Defined in:
lib/bparity/boundary.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ Subject

Returns a new instance of Subject.



6
7
8
# File 'lib/bparity/boundary.rb', line 6

def initialize(name:, **)
  super(name:, method_names: [], excluded: [], return_projections: {})
end

Instance Attribute Details

#excludedObject

Returns the value of attribute excluded

Returns:

  • (Object)

    the current value of excluded



5
6
7
# File 'lib/bparity/boundary.rb', line 5

def excluded
  @excluded
end

#method_namesObject

Returns the value of attribute method_names

Returns:

  • (Object)

    the current value of method_names



5
6
7
# File 'lib/bparity/boundary.rb', line 5

def method_names
  @method_names
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



5
6
7
# File 'lib/bparity/boundary.rb', line 5

def name
  @name
end

#return_projectionsObject

Returns the value of attribute return_projections

Returns:

  • (Object)

    the current value of return_projections



5
6
7
# File 'lib/bparity/boundary.rb', line 5

def return_projections
  @return_projections
end

#state_projectionObject

Returns the value of attribute state_projection

Returns:

  • (Object)

    the current value of state_projection



5
6
7
# File 'lib/bparity/boundary.rb', line 5

def state_projection
  @state_projection
end

Instance Method Details

#exclude(*names) ⇒ Object



14
15
16
# File 'lib/bparity/boundary.rb', line 14

def exclude(*names)
  self.excluded |= names.map(&:to_sym)
end

#methods(*names) ⇒ Object



10
11
12
# File 'lib/bparity/boundary.rb', line 10

def methods(*names)
  self.method_names = names.map(&:to_sym)
end

#observed_methods(target) ⇒ Object



26
27
28
# File 'lib/bparity/boundary.rb', line 26

def observed_methods(target)
  (method_names.empty? ? target.public_instance_methods(false) : method_names) - excluded
end

#project_return(class_name, &block) ⇒ Object



22
23
24
# File 'lib/bparity/boundary.rb', line 22

def project_return(class_name, &block)
  return_projections[class_name] = block
end

#state(&block) ⇒ Object



18
19
20
# File 'lib/bparity/boundary.rb', line 18

def state(&block)
  self.state_projection = block
end