Class: Flipper::Types::Actor
- Inherits:
-
Flipper::Type
- Object
- Flipper::Type
- Flipper::Types::Actor
- Defined in:
- lib/flipper/types/actor.rb
Instance Attribute Summary collapse
-
#thing ⇒ Object
readonly
Returns the value of attribute thing.
Attributes inherited from Flipper::Type
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(thing) ⇒ Actor
constructor
A new instance of Actor.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to?(*args) ⇒ Boolean
Methods inherited from Flipper::Type
Constructor Details
#initialize(thing) ⇒ Actor
Returns a new instance of Actor.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/flipper/types/actor.rb', line 11 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
28 29 30 |
# File 'lib/flipper/types/actor.rb', line 28 def method_missing(name, *args, &block) @thing.send name, *args, &block end |
Instance Attribute Details
#thing ⇒ Object (readonly)
Returns the value of attribute thing.
9 10 11 |
# File 'lib/flipper/types/actor.rb', line 9 def thing @thing end |
Class Method Details
.wrappable?(thing) ⇒ Boolean
4 5 6 7 |
# File 'lib/flipper/types/actor.rb', line 4 def self.wrappable?(thing) return false if thing.nil? thing.respond_to?(:flipper_id) end |
Instance Method Details
#respond_to?(*args) ⇒ Boolean
24 25 26 |
# File 'lib/flipper/types/actor.rb', line 24 def respond_to?(*args) super || @thing.respond_to?(*args) end |