mustmodify / valuable

quick ruby modeling -- basically attr_accessor with default values, light-weight casting, and a constructor
http://valuable.mustmodify.com/
MIT License
72 stars 3 forks source link

Rails collections aren't seen as collections #6

Closed mustmodify closed 9 years ago

mustmodify commented 9 years ago

We assume that collections must be a kind of array. If not, we don't set them. In rails, a collection of results does not appear to be a kind of collection.

class Search < Valuable
  has_collection :employees
end

>> Search.new(employees: Employee.where(true)).employees
=> nil

See https://github.com/mustmodify/valuable/blob/master/lib/valuable/utils.rb#L51-L52 and:

>> Model.where(true).class
=> ActiveRecord::Relation

>> Model.where(true).kind_of? Array
=> false