Sha256: 3ad8a9790dfb2ad250b04659e949a236812ce4537c386d88d7b8513a96ea1870

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module RailsAssist::Artifact
  module Marker
    def marker name, type, options=nil
      method = "#{type}_marker"
      raise "No such marker method in this context: #{self}, ##{method}" if !respond_to? method
      send method, name, options
    end
  end

  module Controller
    def controller_marker name, options=nil
      "#{name.to_s.camelize}Controller < ActionController::Base"
    end

    extend self
  end

  module Helper
    def helper_marker name, options=nil
      "#{name.to_s.camelize}Helper"
    end

    extend self
  end

  module Permit
    def permit_marker name, options=nil
      "#{name.to_s.camelize}Permit < Permit::Base"
    end

    extend self
  end

  module Mailer
    def mailer_marker name, options=nil
      "#{name.to_s.camelize}Mailer < ActionMailer::Base"
    end

    extend self
  end

  module Observer
    def observer_marker name, options=nil
      "#{name.to_s.camelize}Observer < ActiveRecord::Observer"
    end

    extend self
  end

  module Migration
    def migration_marker name, options=nil
      "#{name.to_s.camelize} < ActiveRecord::Migration"
    end

    extend self
  end

  module Model
    include RailsAssist::BaseHelper

    def model_marker name, options={}
      return send :orm_marker_name, name, options if respond_to?(:orm_marker_name)
      name.to_s.camelize
    end

    def orm_notify
      ". You must specify an ORM with the macro use_orm, f.ex -- use_orm :active_record"
    end

    extend self
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_artifactor-0.5.1 lib/rails_artifactor/artifact/markers.rb