Sha256: 68c3a49e7598fc00ca5c48d1486fcd474d11ee0cbf4a830621e738002c069b8a

Contents?: true

Size: 1.34 KB

Versions: 14

Compression:

Stored size: 1.34 KB

Contents

module Chanko
  module Unit
    class Extender
      module ActiveRecordClassMethods
        delegate(
          :apply_modules,
          :arel,
          :array_of_strings?,
          :build_arel,
          :build_joins,
          :build_select,
          :build_where,
          :create_with,
          :custom_join_sql,
          :eager_load,
          :extending,
          :from,
          :group,
          :having,
          :includes,
          :joins,
          :limit,
          :lock,
          :offset,
          :order,
          :preload,
          :readonly,
          :reorder,
          :reverse_order,
          :reverse_sql_order,
          :scope,
          :select,
          :where,
          :to => :@mod
        )

        %w[belongs_to has_many has_one].each do |method_name|
          class_eval <<-EOS
            def #{method_name}(*args, &block)
              label   = args.shift.to_s
              name    = @prefix + label
              options = args.extract_options!
              options = options.reverse_merge(:class_name => label.singularize.camelize)
              args << options
              @mod.#{method_name}(name.to_sym, *args, &block)
            end
          EOS
        end

        def scope(*args, &block)
          name = @prefix + args.shift.to_s
          @mod.scope(name, *args)
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
chanko-2.3.0 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.2.1 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.2.0 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.1.1 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.1.0 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.8 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.7 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.6 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.5 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.4 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.3 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.2 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.1 lib/chanko/unit/extender/active_record_class_methods.rb
chanko-2.0.0 lib/chanko/unit/extender/active_record_class_methods.rb