Document.fields does not contain timestamps #52

Closed
ajselvig opened this Issue Jan 3, 2014 · 6 comments

Comments

Projects
None yet
2 participants
@ajselvig
Contributor

ajselvig commented Jan 3, 2014

I'm accessing document metadata with Document.fields and I don't see created_at or updated_at (I have not disabled timestamps in the config).

@nviennot

This comment has been minimized.

Show comment
Hide comment
@nviennot

nviennot Jan 3, 2014

Owner

Can't reproduce in my REPL:

~/brainy (development) > class Model
~/brainy (development) *   include NoBrainer::Document
~/brainy (development) * end  
=> class #<Class:0x00000005cf47c0>::Model < Object {
            :id => :object,
    :created_at => :object,
    :updated_at => :object
}
~/brainy (development) > Model.fields
=> {
            :id => {
        :default => #<Proc:0x00000005b25c28@/home/pafy/nobrainer/lib/no_brainer/document/id.rb:9 (lambda)>
    },
    :created_at => {},
    :updated_at => {}
}
Owner

nviennot commented Jan 3, 2014

Can't reproduce in my REPL:

~/brainy (development) > class Model
~/brainy (development) *   include NoBrainer::Document
~/brainy (development) * end  
=> class #<Class:0x00000005cf47c0>::Model < Object {
            :id => :object,
    :created_at => :object,
    :updated_at => :object
}
~/brainy (development) > Model.fields
=> {
            :id => {
        :default => #<Proc:0x00000005b25c28@/home/pafy/nobrainer/lib/no_brainer/document/id.rb:9 (lambda)>
    },
    :created_at => {},
    :updated_at => {}
}
@ajselvig

This comment has been minimized.

Show comment
Hide comment
@ajselvig

ajselvig Jan 3, 2014

Contributor

Very strange. I just reproduced with a very simple example:

require 'nobrainer'

class MyModel
    include NoBrainer::Document

end

MyModel.fields.each_key do |name|
    puts "Field #{name}: #{MyModel.fields[name]}"
end

Produces:

Field id: {:default=>#<Proc:0x007ff17598a698@/Users/andy/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nobrainer-113d37cea1f6/lib/no_brainer/document/id.rb:9 (lambda)>}
Contributor

ajselvig commented Jan 3, 2014

Very strange. I just reproduced with a very simple example:

require 'nobrainer'

class MyModel
    include NoBrainer::Document

end

MyModel.fields.each_key do |name|
    puts "Field #{name}: #{MyModel.fields[name]}"
end

Produces:

Field id: {:default=>#<Proc:0x007ff17598a698@/Users/andy/.rvm/gems/ruby-2.0.0-p247/bundler/gems/nobrainer-113d37cea1f6/lib/no_brainer/document/id.rb:9 (lambda)>}
@nviennot

This comment has been minimized.

Show comment
Hide comment
@nviennot

nviennot Jan 3, 2014

Owner

I see, I have the same issue if NoBrainer.configure { } is never called.

Owner

nviennot commented Jan 3, 2014

I see, I have the same issue if NoBrainer.configure { } is never called.

@ajselvig

This comment has been minimized.

Show comment
Hide comment
@ajselvig

ajselvig Jan 3, 2014

Contributor

It must be something more than that. I get the same results with:

class MyModel
    include NoBrainer::Document
end

NoBrainer.configure do |config|
end

MyModel.fields.each_key do |name|
    puts "Field #{name}: #{MyModel.fields[name]}"
end
Contributor

ajselvig commented Jan 3, 2014

It must be something more than that. I get the same results with:

class MyModel
    include NoBrainer::Document
end

NoBrainer.configure do |config|
end

MyModel.fields.each_key do |name|
    puts "Field #{name}: #{MyModel.fields[name]}"
end
@nviennot

This comment has been minimized.

Show comment
Hide comment
@nviennot

nviennot Jan 3, 2014

Owner

configure before declaring the class

Owner

nviennot commented Jan 3, 2014

configure before declaring the class

@ajselvig

This comment has been minimized.

Show comment
Hide comment
@ajselvig

ajselvig Jan 3, 2014

Contributor

Gotcha. Thanks.

Contributor

ajselvig commented Jan 3, 2014

Gotcha. Thanks.

@nviennot nviennot closed this in 384b8b4 Jan 3, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment