Bug #6814

Interface actions should be represented by an object

Added by Nick Lewis about 2 years ago. Updated about 2 years ago.

Status:AcceptedStart date:03/22/2011
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:-
Target version:-
Affected Puppet version: Branch:
Keywords:

Description

This will allow us to define meta-data about an action, such as description and its options.

History

#1 Updated by Daniel Pittman about 2 years ago

When we implement this we should have two objects involved in the process:

class Action
    attr_accessor :desc, :whatever, :else
end

class Action::Builder
    def self.build
        @action = Action.new
        builder = Action::Builder.new(@action)
        builder.instance_eval(...)
    end

    def desc(text)
        @action.desc = text
    end
end

This gives us a nice separation between syntax sugar and clean API; using the same name for the accessor on the instance, and the sugar method on the builder, means that we have consistent naming and don’t surprise people.

Also available in: Atom PDF