lib/formular/element.rb
# Options passed into our element instance (@options) take precident over class level defaults
# Take each default value and merge it with options.
# This way ordering is important and we can access values as they are evaluated
Options passed into our element instance (@options) take precident over class level defaults
Take each default value and merge it with options.
This way ordering is important and we can access values as they are evaluated
Options passed into our element instance ( @options ) take precident over class level defaults Take each default value and merge it with options . This way ordering is important and we can access values as they are evaluated
def normalize_options
      self.class.default_hash.each do |key, hash|
        should_merge = key.to_s.include?('class') && !options[key].nil?
        next if options.has_key?(key) && !should_merge
        next unless evaluate_option_condition?(hash[:condition])
        val = Uber::Options::Value.new(hash[:value]).evaluate(self)
        next if val.nil?
        should_merge ? @options[key] += val : @options[key] = val
      end
    end
def normalize_options self . class . default_hash . each do | key , hash | should_merge = key . to_s . include? ( 'class' ) && ! options [ key ] . nil? next if options . has_key? ( key ) && ! should_merge next unless evaluate_option_condition? ( hash [ :condition ] ) val = Uber :: Options :: Value . new ( hash [ :value ] ) . evaluate ( self ) next if val . nil? should_merge ? @options [ key ] += val : @options [ key ] = val end end
Options passed into our element instance (@options) take precident over class level defaults
Take each default value and merge it with options.
Options passed into our element instance ( @options ) take precident over class level defaults Take each default value and merge it with options .
# if our default is conditional and the condition evaluates to false then skip # if our default value is nil then skip # otherwise perform the actual merge, classes get joined, otherwise we overwrite