Sha256: b9b4c453eb1d1986ad877001db97a8ec744d533fb10b235c3b152811531868d7

Contents?: true

Size: 698 Bytes

Versions: 8

Compression:

Stored size: 698 Bytes

Contents

module DynamicScaffold
  module JSONObject
    module Attribute
      extend ActiveSupport::Concern

      included do
        @json_object_attribute_names ||= []

        define_method :valid? do |context = nil|
          result = super(context)
          json_object_attribute_names = self.class.instance_variable_get(:@json_object_attribute_names)
          json_object_attribute_names.all? {|method| public_send(method).valid?(context) } && result
        end
      end

      module ClassMethods
        def json_object_attributte(attribute_name, model)
          @json_object_attribute_names << attribute_name
          serialize attribute_name, model
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dynamic_scaffold-1.12.2 lib/dynamic_scaffold/json_object/attribute.rb
dynamic_scaffold-1.12.1 lib/dynamic_scaffold/json_object/attribute.rb
dynamic_scaffold-1.12.0 lib/dynamic_scaffold/json_object/attribute.rb
dynamic_scaffold-1.11.0 lib/dynamic_scaffold/json_object/attribute.rb
dynamic_scaffold-1.10.0 lib/dynamic_scaffold/json_object/attribute.rb
dynamic_scaffold-1.9.0 lib/dynamic_scaffold/json_object/attribute.rb
dynamic_scaffold-1.8.1 lib/dynamic_scaffold/json_object/attribute.rb
dynamic_scaffold-1.8.0 lib/dynamic_scaffold/json_object/attribute.rb