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.2.2 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.1 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.8 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.7 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.6 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.5 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.4 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.3 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.2 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.1 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.2.0.0 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.25 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.24 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.23 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.22 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.21 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.20 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.19 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.18 app/models/c80_map_floors/base_map_object.rb
c80_map_floors-0.1.0.17 app/models/c80_map_floors/base_map_object.rb