Skip to content

Instantly share code, notes, and snippets.

@adambeynon
Created December 15, 2013 09:57
Show Gist options
  • Save adambeynon/7970981 to your computer and use it in GitHub Desktop.
Save adambeynon/7970981 to your computer and use it in GitHub Desktop.
class User < Vienna::Model
attributes :first_name, :last_name
end
user = User.new
first = Frappuccino::Stream.new(user).capture(:changed_first_name)
last = Frappuccino::Stream.new(user).capture(:changed_last_name)
# last name is any change to first or last name
last_name = first.merge(last).map { "#{user.first_name} #{user.last_name}" }
user.first_name = "Ford"
last_name.now # => "Ford "
user.last_name = "Prefect"
last_name.now # => "Ford Prefect"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment