<commit_before>###
Base class for Atom

@namespace Atoms.Class
@class Atom

@author <NAME> <<EMAIL>> || @soyjavi
###
"use strict"

class Atoms.Class.Atom extends Atoms.Core.Module

  @include Atoms.Core.Attributes
  @include Atoms.Core.Event
  @include Atoms.Core.Output

  @type    = "Atom"
  @default = {}

  constructor: (@attributes) ->
    super
    @attributes = Atoms.Core.Helper.mix @attributes, @constructor.default

    do @scaffold
    if @entity
      attributes = @entity.parse?() or @entity.attributes()
      @attributes = Atoms.Core.Helper.mix @attributes, attributes
      EVENT = Atoms.Core.Constants.ENTITY.EVENT
      if @attributes.bind.update
        Atoms.Entity[@entity.className].bind EVENT.UPDATE, @bindEntityUpdate
      if @attributes.bind.destroy
        Atoms.Entity[@entity.className].bind EVENT.DESTROY, @bindEntityDestroy
    do @output
    @bindEvents()

  bindEntityUpdate: (model) =>
    if model.uid is @entity.uid
      attributes = @entity.parse?() or @entity.attributes()
      @attributes[attribute] = attributes[attribute] for attribute of attributes
      do @refresh

  bindEntityDestroy: (model) =>
    do @destroy if model.uid is @entity.uid

  bindEvents: ->
    if @attributes.events
      for evt in @attributes.events
        @el.on evt, do (evt) => (event) => @bubble evt, event<commit_msg>Only dispatch event if el doesn't have disabled attribute<commit_after>###
Base class for Atom

@namespace Atoms.Class
@class Atom

@author <NAME> <<EMAIL>> || @soyjavi
###
"use strict"

class Atoms.Class.Atom extends Atoms.Core.Module

  @include Atoms.Core.Attributes
  @include Atoms.Core.Event
  @include Atoms.Core.Output

  @type    = "Atom"
  @default = {}

  constructor: (@attributes) ->
    super
    @attributes = Atoms.Core.Helper.mix @attributes, @constructor.default

    do @scaffold
    if @entity
      attributes = @entity.parse?() or @entity.attributes()
      @attributes = Atoms.Core.Helper.mix @attributes, attributes
      EVENT = Atoms.Core.Constants.ENTITY.EVENT
      if @attributes.bind.update
        Atoms.Entity[@entity.className].bind EVENT.UPDATE, @bindEntityUpdate
      if @attributes.bind.destroy
        Atoms.Entity[@entity.className].bind EVENT.DESTROY, @bindEntityDestroy
    do @output
    @bindEvents()

  bindEntityUpdate: (model) =>
    if model.uid is @entity.uid
      attributes = @entity.parse?() or @entity.attributes()
      @attributes[attribute] = attributes[attribute] for attribute of attributes
      do @refresh

  bindEntityDestroy: (model) =>
    do @destroy if model.uid is @entity.uid

  bindEvents: ->
    if @attributes.events
      for event in @attributes.events
        @el.on event, do (event) => (handler) =>
          unless @el[0].disabled is true then @bubble event, handler
{'fraction_non_alphanumeric': 0.12104885057471264, 'fraction_numerical': 0.00035919540229885057, 'mean_word_length': 3.3044822256568778, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '738958', 'n_tokens_mistral': 847, 'n_tokens_neox': 833, 'n_words': 218}