Sha256: 2ea7384adf0de297dd69ffadedca167336815622d08c2b6b66e806a79c42c099

Contents?: true

Size: 919 Bytes

Versions: 18

Compression:

Stored size: 919 Bytes

Contents

module Unidom::Category::Concerns::AsCategory

  extend ActiveSupport::Concern

  included do |includer|

    has_many :categorizings, class_name: 'Category::Categorizing'

    def categorize!(categorized, at: Time.now, primary: true)

      raise ArgumentError('The categorized argument is required.') if categorized.blank?
      raise ArgumentError('The at argument is required.'         ) if at.blank?

      categorizings.categorized_is(categorized).valid_at(now: at).alive.first_or_create! elemental: primary, opened_at: at

    end

    def categorize?(categorized, at: Time.now, primary: true)

      raise ArgumentError('The categorized argument is required.') if categorized.blank?
      raise ArgumentError('The at argument is required.'         ) if at.blank?

      categorizings.categorized_is(categorized).valid_at(now: at).alive.primary(primary).exists?

    end

  end

  module ClassMethods
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
unidom-category-2.0 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6.8 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6.7 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6.6 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6.5 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6.4 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6.3 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6.2 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6.1 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.6 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.5.5 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.5.4 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.5.3 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.5.2 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.5.1 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.5 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.4 app/models/unidom/category/concerns/as_category.rb
unidom-category-1.3 app/models/unidom/category/concerns/as_category.rb