Sha256: f762d61d7a06cce709270344f4b860b5f33af060105ce241fea039939749ed12

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

module RailsAssist
  module BaseHelper
    def self.included(base)
      base.extend ClassMethods
      base.class_eval do
        include RailsAssist::App
        # include ::Thor::Actions
      end
    end

    module ClassMethods
      def multi_aliases_for name
        multi_alias :_after_ => name, :create => :new, :insert_into => [:inject_into, :update], :read => :X_content, :remove => :delete                    
      end
    end

    protected

    def get_type options = {}
      case options
      when Hash
        raise ArgumentError, "No artifact type specified #{options}" if !options[:type]
        options[:type].to_sym
      when String, Symbol
        options.to_sym
      else
        raise ArgumentError, "Bad artifact type specified #{options}"
      end
    end

    def debug?
      RailsAssist.debug_on
    end

    def debug msg
      puts msg if debug?
    end

    def set options, type
      options.merge!(:type => type)
      options
    end

    def orm_notify
      ''
    end

    def marker_option name, options={}
      type = last_option(options)[:type]
      marker_content = if type
        method = :"#{type}_marker"
        orm_marker = send method, name, options if respond_to? method 
      else
        name.to_s.camelize
      end
      options[:before] ? {:before => marker_content} : {:after => marker_content}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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