Skip to content

Class attribute defaults not being generated #4

@tcd

Description

@tcd

Given the following YAML code, ginny generates the following ruby code (with no default value for created_at):

---
name: Post
description: This is an example
modules: [App]
parent: ApplicationRecord
default_constructor: true
attrs:
- { name: id,         type: String }
- { name: created_at, type: Time, default: "Time.now()" }
- { name: updated_at, type: Time }
module App
  # This is an example
  class Post < ApplicationRecord
    # @return [String]
    attr_accessor :id
    # @return [Time]
    attr_accessor :created_at
    # @return [Time]
    attr_accessor :updated_at

    # @param params [Hash]
    # @return [self]
    def self.create(params = {})
      p = Post.new
      p.id = params[:id]
      p.created_at = params[:created_at]
      p.updated_at = params[:updated_at]
      return p
    end
  end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions