Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create OPF1.3 ruby action classes #10

Open
nickkaranatsios opened this issue Jan 18, 2013 · 1 comment
Open

Create OPF1.3 ruby action classes #10

nickkaranatsios opened this issue Jan 18, 2013 · 1 comment
Assignees

Comments

@nickkaranatsios
Copy link
Member

OPF1.3 has many actions and most actions have some attributes therefore a common way to declare and validate attributes of such actions is needed. At the moment I am inclining to use the pattern used with activerecord validations. An example is always best.

class Action
  include ActionHelper
end

class PushMpls < Action
  def initialize ether_type
    create_validate : :ether_type, :presence => true, :within => "ether_type_range", :validate_with => "unsigned_16bit_number", :value => ether_type
  end

The above create_validate method would create the attribute ether_type and raise an exception if no value is given and for example call the validation functions ether_type_range and unsigned_16bit_number.

@ghost ghost assigned nickkaranatsios Jan 18, 2013
@yasuhito
Copy link
Member

👍

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

No branches or pull requests

2 participants