Class: MrDarcy::Role

Inherits:
Object
  • Object
show all
Defined in:
lib/mr_darcy/role.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, opts = {}, &block) ⇒ Role

Returns a new instance of Role.



5
6
7
8
9
# File 'lib/mr_darcy/role.rb', line 5

def initialize name, opts={}, &block
  self.name    = name
  self.options = opts
  @module = Module.new(&block)
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/mr_darcy/role.rb', line 3

def name
  @name
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/mr_darcy/role.rb', line 3

def options
  @options
end

Instance Method Details

#clean(player) ⇒ Object



21
22
23
# File 'lib/mr_darcy/role.rb', line 21

def clean player
  clean_singleton_methods player unless jruby?
end

#pollute(player) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/mr_darcy/role.rb', line 11

def pollute player
  guard_against_false_players player

  if jruby?
    pollute_with_module_extension player
  else
    pollute_with_singleton_methods player
  end
end