Skip to content

get rid of params wrapper - directly access params via instance vars #51

Closed
@catmando

Description

@catmando

instead of params.foo we should just say @foo

why?

  1. its 25 times faster
  2. its much more consistent - all component state is in instance vars regardless of how it is set
  3. the params wrapper method is not private (but it should be)
  4. less typing
  5. it just feels more natural to ruby.

Don't worry - you can get the legacy behavior by adding param_accessor_style :legacy to any component (including the base component.) You can also say param_accessor_style :both to get both behaviors. If you need to switch back to the now standard behavior say param_accessor_style :hyperstack

So for example you can say param_accessor_style :legacy in your base component, and then as you update components to new style in that component say param_accessor_style :hyperstack.

The param declaration macro is unchanged, but has a new alias option.

param :foo, alias: :internal_name

If you like to distinguish between params and other instance variables you can use this feature like this:

param :foo, alias: :param_foo for example

see #52 for a complete example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions