Sha256: aaa3208daaf0c8452885e8c292cdd666ed1a7ddb2b28bb866ae676e6120ea4b3

Contents?: true

Size: 1.05 KB

Versions: 14

Compression:

Stored size: 1.05 KB

Contents

class TodoItem < ActiveRecord::Base

  def view_permitted?(attribute)
    !acting_user or user_is? acting_user
  end

  def update_permitted?
    return true unless acting_user
    return only_changed? :comments unless user_is? acting_user
    true
  end

  belongs_to :user
  has_many :comments
  has_many :commenters, class_name: "User", through: :comments, source: :user
  belongs_to :comment # just so we can test an empty belongs_to relationship

  scope :find_string, ->(s) { where("title LIKE ? OR description LIKE ?", "%#{s}%", "%#{s}%") }

  scope :active, -> { where("title LIKE '%mitch%' OR description LIKE '%mitch%'")}
  # to_sync :active do |scope, record|
  #   if record.title =~ /mitch/ || record.description =~ /mitch/
  #     scope << record
  #   else
  #     scope.delete(record)
  #   end
  # end

  scope :important, -> { where("title LIKE '%another%' OR description LIKE '%another%'")}
  # to_sync(:important) {title =~ /another/ || description =~ /another/ }

  def virtual_user_first_name
    user.first_name
  end unless RUBY_ENGINE == 'opal'

end

Version data entries

14 entries across 7 versions & 1 rubygems

Version Path
hyper-mesh-0.6.0 spec/test_app/app/models/public/todo_item.rb
hyper-mesh-0.6.0 reactive_record_test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.4 spec/test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.4 reactive_record_test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.3 reactive_record_test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.3 spec/test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.2 spec/test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.2 reactive_record_test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.1 spec/test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.1 reactive_record_test_app/app/views/models/todo_item.rb
hyper-mesh-0.5.0 spec/test_app/app/models/public/todo_item.rb
hyper-mesh-0.5.0 reactive_record_test_app/app/views/models/todo_item.rb
hyper-mesh-0.4.0 reactive_record_test_app/app/views/models/todo_item.rb
hyper-mesh-0.4.0 spec/test_app/app/models/public/todo_item.rb