adomokos / light-service

Series of Actions with an emphasis on simplicity.
MIT License
837 stars 67 forks source link

Return a false value from a context when using [] syntax. #95

Closed bschmeck closed 8 years ago

adomokos commented 8 years ago

This change will make the tests pass:

def [](key)
  hash_value = super(key) if key?(key)
  return hash_value unless hash_value.nil?

  super(aliases.key(key))
end

I don't think this is the best solution, as it only makes assumptions on the values. What if the hash_value is set to nil?

bschmeck commented 8 years ago

Pushed a change to use the key's alias if there is one, otherwise just do a normal lookup.

Because aliases are keys in the context in their own right, this method could be removed and the standard Hash#[] method could be used. But that causes a failing spec due to an inconsistency with aliases. Working on that in a separate branch.

bschmeck commented 8 years ago

Branch showing issues with context aliases is here: https://github.com/bschmeck/light-service/tree/context-alias-bugs

Diff is here: https://github.com/adomokos/light-service/compare/master...bschmeck:context-alias-bugs

adomokos commented 8 years ago

Thank you! I won't release a new version until you (we) have a chance to resolve that alias bug. 👍