Class: Resourced::Attributes::ConditionalGroup
- Inherits:
-
Object
- Object
- Resourced::Attributes::ConditionalGroup
- Defined in:
- lib/resourced/attributes.rb
Instance Attribute Summary collapse
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
Instance Method Summary collapse
-
#initialize(condition, fields) ⇒ ConditionalGroup
constructor
A new instance of ConditionalGroup.
- #test(context) ⇒ Object
Constructor Details
#initialize(condition, fields) ⇒ ConditionalGroup
Returns a new instance of ConditionalGroup.
169 170 171 172 173 174 175 176 177 178 |
# File 'lib/resourced/attributes.rb', line 169 def initialize(condition, fields) @condition = case condition when Symbol, String lambda { send(condition.to_sym) } when Proc condition end @fields = fields end |
Instance Attribute Details
#fields ⇒ Object (readonly)
Returns the value of attribute fields.
180 181 182 |
# File 'lib/resourced/attributes.rb', line 180 def fields @fields end |
Instance Method Details
#test(context) ⇒ Object
182 183 184 |
# File 'lib/resourced/attributes.rb', line 182 def test(context) !!context.instance_exec(&@condition) end |