Skip to content

Question about command pattern in Ruby #16

Description

@RomanADavis

I've actually wanted to use a pattern like this in Ruby, where I've wanted an object to do some nonstandard behavior and then do some standard behavior. For example, an OpCode class that executes a certain operation argument then changes the value of the address in memory for a simple emulator, or a Spell class that checks if the Character casting it has enough magic_points to cast the spell, fails if it doesn't, subtracts mp_cost argument from the character casting it and executes the spell_formula argument.

The thing is, in Ruby I didn't create a special operation or spell_formula class to pass around a method / command as an argument. I used a lambda.

It would be nice if the description of this pattern was expanded to include the pros and cons of this method, since from my perspective it just seems like the natural and dare-I-say-it, ruby way to do things.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions