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

Default attribute type and options in Attributor model #112

Open
konstantin-dzreev opened this issue Mar 17, 2015 · 0 comments
Open

Default attribute type and options in Attributor model #112

konstantin-dzreev opened this issue Mar 17, 2015 · 0 comments
Milestone

Comments

@konstantin-dzreev
Copy link
Contributor

Attributor::Model definition tends to look heavy. It would be nice to have a default type and default options for its attributes when you define a model.
How it is:

    class Definition < Attributor::Model
      attributes do
        attribute :action, String, required: true
        attribute :project_id, String, required: true
        attribute :resource_type, String, required: true
        attribute :service, String, required: true
        attribute :service_id, String, required: true
        attribute :status, String, required: true
        attribute :task_id, String, required: true
        attribute :vendor, String, required: true
        attribute :tracking_number, String
        attribute :output, Hash
      end
    end

How it could look like:

    class Definition < Attributor::Model
      attributes(String, required:true) do
        attribute :action
        attribute :project_id
        attribute :resource_type
        attribute :service
        attribute :service_id
        attribute :status
        attribute :task_id
        attribute :vendor
        attribute :tracking_number, required: false
        attribute :output, Hash, required: false
      end
    end
end

where "String" is a default attribute type and default value for "required" is "true".

@careo careo added this to the v4.3 milestone Nov 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants