Sha256: 3742eec56b962c4e07a114550d9e653011251c20e8039aec22efd5e42623e2bd

Contents?: true

Size: 434 Bytes

Versions: 8

Compression:

Stored size: 434 Bytes

Contents

class Structure
  # Converts structure to a JSON representation.
  def as_json(options = nil)
    subset = if options
      if only = options[:only]
        attributes.slice(*Array.wrap(only))
      elsif except = options[:except]
        attributes.except(*Array.wrap(except))
      else
        attributes.dup
      end
    else
      attributes.dup
    end

    { JSON.create_id => self.class.name }.
      merge(subset)
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
structure-0.21.0 lib/structure/ext/active_support.rb
structure-0.20.1 lib/structure/active_support.rb
structure-0.20.0 lib/structure/active_support.rb
structure-0.19.0 lib/structure/rails.rb
structure-0.18.0 lib/structure/rails.rb
structure-0.17.3 lib/structure/rails.rb
structure-0.17.2 lib/structure/rails.rb
structure-0.17.1 lib/structure/rails.rb