Sha256: cbc5ab8af7814d485ed43e0dafb684c3a025b97ccf80149b5276558c195962ec

Contents?: true

Size: 872 Bytes

Versions: 2

Compression:

Stored size: 872 Bytes

Contents

module ActiveData
  module Attributes
    class Localized < Base

      def default_value *args
        {}
      end

      def generate_instance_methods context
        context.class_eval <<-EOS
          def #{name}_translations
            read_attribute(:#{name})
          end

          def #{name}_translations= value
            write_attribute(:#{name}, value)
          end

          def #{name}
            read_localized_attribute(:#{name})
          end

          def #{name}= value
            write_localized_attribute(:#{name}, value)
          end

          def #{name}?
            read_localized_attribute(:#{name}).present?
          end

          def #{name}_before_type_cast
            read_localized_attribute_before_type_cast(:#{name})
          end
        EOS
      end

      def generate_class_methods context
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
active_data-0.3.0 lib/active_data/attributes/localized.rb
active_data-0.2.0 lib/active_data/attributes/localized.rb