Class: AdequateExposure::Context
- Inherits:
-
Object
- Object
- AdequateExposure::Context
- Defined in:
- lib/adequate_exposure/context.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
Instance Method Summary collapse
-
#get ⇒ Object
Public: Read an attribute on the context Class.
-
#initialize(context, attribute) ⇒ Context
constructor
Public: Initialize a context.
-
#set(value) ⇒ Object
Public: Write to an attribute on the context Class.
Constructor Details
#initialize(context, attribute) ⇒ Context
Public: Initialize a context.
context - The Class where the attribute is defined. attribute - The attribute that will be accessed by a getter
and setter.
10 11 12 |
# File 'lib/adequate_exposure/context.rb', line 10 def initialize(context, attribute) @context, @attribute = context, attribute end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
3 4 5 |
# File 'lib/adequate_exposure/context.rb', line 3 def attribute @attribute end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
3 4 5 |
# File 'lib/adequate_exposure/context.rb', line 3 def context @context end |
Instance Method Details
#get ⇒ Object
Public: Read an attribute on the context Class.
Get an attribute’s value. If the attribute’s instance variable is not defined, it will create one, execute attribute#fetch, and assign the result to the instance variable.
Returns the attribute’s value.
22 23 24 |
# File 'lib/adequate_exposure/context.rb', line 22 def get ivar_defined?? ivar_get : set(fetch_value) end |
#set(value) ⇒ Object
Public: Write to an attribute on the context Class.
value - The value that will be set to the attribute’s
instance variable.
Returns the attribute’s value.
32 33 34 |
# File 'lib/adequate_exposure/context.rb', line 32 def set(value) ivar_set(value) end |