Sha256: d2ebc8c80daf0b4d03856ab40d76d836160e9536803d0608254f6502429f6127

Contents?: true

Size: 952 Bytes

Versions: 6

Compression:

Stored size: 952 Bytes

Contents

module Rooftop
  module Content
    class Field < ::OpenStruct

      #todo - this would be nice to get working. For a relationship, we should be returning the object not a big hash
      # def initialize(hash=nil)
      #   if hash.has_key?(:type) && hash[:type] == "relationship"
      #     related_objects = [hash[:value]].flatten
      #     hash[:value] = related_objects.inject([]) do |array,object|
      #       begin
      #         klass = Rooftop.configuration.post_type_mapping[object[:post_type].to_sym] || object[:post_type].to_s.classify.constantize
      #         array << klass.new(object).run_callbacks(:find)
      #       rescue
      #         array << object
      #       end
      #     end
      #     super
      #   else
      #     super
      #   end
      # end



      def to_s
        if respond_to?(:value) && value.is_a?(String)
          value
        else
          inspect
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rooftop-0.1.4.1 lib/rooftop/content/field.rb
rooftop-0.1.4 lib/rooftop/content/field.rb
rooftop-0.1.3 lib/rooftop/content/field.rb
rooftop-0.1.2 lib/rooftop/content/field.rb
rooftop-0.1.1 lib/rooftop/content/field.rb
rooftop-0.0.7.4 lib/rooftop/content/field.rb