Sha256: 7f02d365a9a3b3e10e82bc9ccd53912ccac2a4a19d03334b469d94197b16bb05

Contents?: true

Size: 904 Bytes

Versions: 4

Compression:

Stored size: 904 Bytes

Contents

<%- if model_config[:extension].present? -%>
require_relative '<%= model_config[:extension][:file] %>'
<%- end -%>

module Tiss::Model
  class <%= model_name %> < <%= model_config[:extension].present? ? model_config[:extension][:class] : 'Base' %>
    <%- attributes.each_key do |key| %>
    # @type: <%= attributes[key].first[:type] %>
    attr_accessor :<%= key.gsub('-', '_') %>
    <% end -%>

    <%- attributes.each_key do |key| -%>
    <%- attr_versions = attributes[key].map{|attr| attr[:version]} -%>
    <%- versions = Tiss.config.available_versions - attr_versions -%>
    <%- if versions.any? && versions.count > 4 -%>
    attribute_config :<%= key.gsub('-', '_') %>, only: %w[<%= attr_versions.join(' ') %>]
    <%- elsif versions.any? && versions.count <= 4 -%>
    attribute_config :<%= key.gsub('-', '_') %>, unless: %w[<%= versions.join(' ') %>]
    <%- end %>
    <%- end -%>
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tiss-ruby-0.2.2 lib/tiss/generator/generators/templates/model_template.erb
tiss-ruby-0.2.1 lib/tiss/generator/generators/templates/model_template.erb
tiss-ruby-0.2.0 lib/tiss/generator/generators/templates/model_template.erb
tiss-ruby-0.1.0 lib/tiss/generator/generators/templates/model_template.erb