Sha256: 479a5a18a5fb753fa3676ad90e70c300c472971f3c3441637b28ac79c709c676

Contents?: true

Size: 568 Bytes

Versions: 3

Compression:

Stored size: 568 Bytes

Contents

class SchofieldFormGenerator < FormGenerator
  
  protected
    
    def add_options!(opt)
      super
      opt.on('--parents PARENTS_PATH',
        "Specify the parents for the specified model.") do |v|
        options[:parents] = v if v.present?
      end
    end
    
    def form_model type='new'
      array = [':admin']
      if type == 'new' && options[:parents].present?
        options[:parents].each do |parent|
          array << "@#{parent}"
        end
      end
      array << "@#{singular_name.singularize}"
      "[#{array.join(', ')}]"
    end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
schofield-0.1.4 generators/schofield_form/schofield_form_generator.rb
schofield-0.1.3 generators/schofield_form/schofield_form_generator.rb
schofield-0.1.2 generators/schofield_form/schofield_form_generator.rb