Sha256: ad1d571a02c5f7f04fa8680578ba93bbcf707a2193b814ebe402ffd10c1ab0cd

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

# TODO: params shouldn't be merge but they must respect the order
# TODO: Add default value for each methods below
# TODO: Factorise codes below
# TODO we must clarified/unified the usage of presets and sanitizer it is not clear

class Atome
  def atome_common(atome_type, params)
    # TODO : optimise the whole code below and make it rubocop friendly
    essential_params = Essentials.default_params[atome_type] || {}
    essential_params[:type] = essential_params[:type] || :element
    essential_params[:renderers] = essential_params[:renderers] || @atome[:renderers]
    essential_params[:id] = params[:id] || identity_generator(atome_type)
    essential_params[:attach] = params[:attach] || [@atome[:id]] || [:view]
    essential_params.merge(params)
  end

  def box(params = {}, &bloc)
    atome_type = :box
    params = atome_common(atome_type, params)
    Atome.new({ atome_type => params }, &bloc)
  end

  def circle(params = {}, &bloc)
    atome_type = :circle
    # puts "counter#{Universe.counter}"

    params = atome_common(atome_type, params)
    # puts "params ==> #{params} : #{Universe.counter}"

    Atome.new({ atome_type => params }, &bloc)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
atome-0.5.4.1.0 lib/atome/presets/atome.rb
atome-0.5.4.0.9 lib/atome/presets/atome.rb