module Composable::Core::ComposableDSL::ClassMethods

Public Instance Methods

composable(attribute, **options, &block) click to toggle source
# File lib/composable/core/composable_dsl.rb, line 14
def composable(attribute, **options, &block)
  composables[attribute.to_sym] ||= Composable.new(attribute)
  composables[attribute.to_sym].evaluate(**options, &block)

  return if attributes.include?(attribute.to_sym)

  attribute attribute

  alias_method "#{attribute}_original_setter=", "#{attribute}="

  define_method("#{attribute}=") do |value|
    send("#{attribute}_original_setter=", value)
    composables[attribute.to_sym].sync_attributes(
      self, composable_record_for(attribute), reverse: true
    )
  end
end