Class: Ruleby::Steel::WhenPropertyBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/dsl/steel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ WhenPropertyBuilder

Returns a new instance of WhenPropertyBuilder.



218
219
220
221
222
# File 'lib/dsl/steel.rb', line 218

def initialize(parent)
  @parent = parent
  @property_hash = Hash.new
  @property_keys = []
end

Instance Attribute Details

#property_hashObject (readonly)

Returns the value of attribute property_hash.



215
216
217
# File 'lib/dsl/steel.rb', line 215

def property_hash
  @property_hash
end

#property_keysObject (readonly)

Returns the value of attribute property_keys.



216
217
218
# File 'lib/dsl/steel.rb', line 216

def property_keys
  @property_keys
end

Instance Method Details

#create(method_id, &block) ⇒ Object



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/dsl/steel.rb', line 224

def create(method_id,&block)
  method = method_id.to_sym
  wp = nil
  if @property_hash.key? method
    wp = @property_hash[method]
  else
    wp = WhenProperty.new @parent, method do |p| true end
    @property_hash[method] = wp
    @property_keys.push method
  end
  if block_given?
    wp.block = block
  end
  return wp
end