Class: Rox::Core::PropertiesExtensions

Inherits:
Object
  • Object
show all
Defined in:
lib/rox/core/repositories/roxx/properties_extensions.rb

Instance Method Summary collapse

Constructor Details

#initialize(parser, properties_repository, dynamic_property_rule_handler = nil) ⇒ PropertiesExtensions

Returns a new instance of PropertiesExtensions.



8
9
10
11
12
# File 'lib/rox/core/repositories/roxx/properties_extensions.rb', line 8

def initialize(parser, properties_repository, dynamic_property_rule_handler = nil)
  @parser = parser
  @properties_repository = properties_repository
  @dynamic_property_rule_handler = dynamic_property_rule_handler
end

Instance Method Details

#extendObject



14
15
16
17
18
19
20
21
22
# File 'lib/rox/core/repositories/roxx/properties_extensions.rb', line 14

def extend
  @parser.add_operator('property') do |_parser, stack, context|
    prop_name = stack.pop.to_s
    property = @properties_repository.custom_property(prop_name)
    value = get_value(prop_name, property, context)

    stack.push(value.nil? ? TokenType::UNDEFINED : value)
  end
end