class VueJs::VuetifyCrudGenerator

Public Instance Methods

create_component_file() click to toggle source
# File lib/generators/vue_js/vuetify_crud/vuetify_crud_generator.rb, line 9
def create_component_file
  template "crud_component.vue.tt", "app/javascript/components/#{plural_name}_crud.vue"
end

Private Instance Methods

attributes_names_without_id() click to toggle source
# File lib/generators/vue_js/vuetify_crud/vuetify_crud_generator.rb, line 15
def attributes_names_without_id
  attributes_without_id.map(&:name)
end
attributes_without_id() click to toggle source
# File lib/generators/vue_js/vuetify_crud/vuetify_crud_generator.rb, line 23
def attributes_without_id
  @attributes_without_id ||= attributes.reject {|attr| attr.type == :primary_key}
end
find_primary_key() click to toggle source
# File lib/generators/vue_js/vuetify_crud/vuetify_crud_generator.rb, line 31
def find_primary_key
  attributes.find {|attribute|
    attribute.type == :primary_key
  }.tap {|attribute|
    raise Thor::RequiredArgumentMissingError, "Error: primary key field is required" if attribute.nil?
  }
end
primary_key_name() click to toggle source
# File lib/generators/vue_js/vuetify_crud/vuetify_crud_generator.rb, line 27
def primary_key_name
  @primary_key_name ||= find_primary_key.name
end
render_attributes_defaults(indentation) click to toggle source
# File lib/generators/vue_js/vuetify_crud/vuetify_crud_generator.rb, line 19
def render_attributes_defaults(indentation)
  attributes_names_without_id.map {|name| "#{name}: null" }.join(",\n#{' ' * indentation}")
end