Class: Flipper::Types::Actor
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(thing) ⇒ Actor
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/flipper/types/actor.rb', line 20
def initialize(thing)
if thing.nil?
raise ArgumentError.new("thing cannot be nil")
end
unless thing.respond_to?(:flipper_id)
raise ArgumentError.new("#{thing.inspect} must respond to flipper_id, but does not")
end
@thing = thing
@value = thing.flipper_id.to_s
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
37
38
39
|
# File 'lib/flipper/types/actor.rb', line 37
def method_missing(name, *args, &block)
@thing.send name, *args, &block
end
|
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
18
19
20
|
# File 'lib/flipper/types/actor.rb', line 18
def value
@value
end
|
Class Method Details
.wrap(thing) ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/flipper/types/actor.rb', line 10
def self.wrap(thing)
if thing.is_a?(Flipper::Types::Actor)
thing
else
new(thing)
end
end
|
.wrappable?(thing) ⇒ Boolean
4
5
6
7
8
|
# File 'lib/flipper/types/actor.rb', line 4
def self.wrappable?(thing)
return false if thing.nil?
return true if thing.is_a?(Flipper::Types::Actor)
thing.respond_to?(:flipper_id)
end
|
Instance Method Details
#respond_to?(*args) ⇒ Boolean
33
34
35
|
# File 'lib/flipper/types/actor.rb', line 33
def respond_to?(*args)
super || @thing.respond_to?(*args)
end
|