Class: Resourced::Attributes::ConditionalGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/resourced/attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fieldsObject (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