Sha256: 01393b1fc962ab55f3fd069131b73085e28645fa09ef881d81b5d4fad416e362

Contents?: true

Size: 1.08 KB

Versions: 33

Compression:

Stored size: 1.08 KB

Contents

module C80MapFloors
  module BaseMapObject

    extend ActiveSupport::Concern

    def self.included(klass)
      klass.extend ClassMethods
      klass.send(:include, InstanceMethods)
    end

    module ClassMethods

      def acts_as_base_map_object
        class_eval do

          # NOTE:: возможно, временно
          # after_save :update_json

          # TODO:: оставить в этом файле только InstanceMethods с class_name

          # TODO?
          # after_destroy :update_json

          # validates :coords, uniqueness: true
          validates_uniqueness_of :coords, :allow_nil => true, :allow_blank => true #-> глючит для Этажей - у них могут быть одинаковые coords

          def update_json
            MapJson.update_json
          end

        end
      end
    end

    module InstanceMethods

      # используется для сопоставления js классов
      def class_name
        self.class.name
      end

    end

  end
end

ActiveRecord::Base.send :include, C80MapFloors::BaseMapObject

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
c80_map_floors-0.1.0.16 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.15 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.14 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.13 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.12 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.11 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.10 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.9 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.8 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.7 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.6 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.5 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.4 app/models/c80_map_floors/base_map_object.rb