Sha256: 1840b3550a8e200dcdd865945e4408486a36e754943f3db35c64251935a13487

Contents?: true

Size: 1.05 KB

Versions: 18

Compression:

Stored size: 1.05 KB

Contents

# An item is a concrete record.
# It can be part of another proxy like collection.
class LHS::Item < LHS::Proxy

  autoload :Destroy,
    'lhs/concerns/item/destroy'
  autoload :Save,
    'lhs/concerns/item/save'
  autoload :Update,
    'lhs/concerns/item/update'
  autoload :Validation,
    'lhs/concerns/item/validation'

  include Create
  include Destroy
  include Save
  include Update
  include Validation

  delegate :map, :present?, :blank?, :empty?, to: :_raw, allow_nil: true
  delegate :_raw, to: :_data

  def collection?
    false
  end

  def item?
    true
  end

  protected

  def method_missing(name, *args, &_block)
    return set(name, args.try(&:first)) if name.to_s[/=$/]
    get(name, *args)
  end

  def respond_to_missing?(name, _include_all = false)
    # We accept every message that does not belong to set of keywords
    !BLACKLISTED_KEYWORDS.include?(name.to_s)
  end

  def unwrap_nested_item
    return _data unless _record.item_key
    nested_data = _data.dig(*_record.item_key)
    return _data unless nested_data
    nested_data
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
lhs-15.3.1 lib/lhs/item.rb
lhs-15.3.1.pre.fixlhc.1 lib/lhs/item.rb
lhs-15.3.0 lib/lhs/item.rb
lhs-15.2.5 lib/lhs/item.rb
lhs-15.2.4 lib/lhs/item.rb
lhs-15.2.3 lib/lhs/item.rb
lhs-15.2.3.pre.favorites.1 lib/lhs/item.rb
lhs-15.2.2.pre.favorites.1 lib/lhs/item.rb
lhs-15.2.2 lib/lhs/item.rb
lhs-15.2.1 lib/lhs/item.rb
lhs-15.2.0 lib/lhs/item.rb
lhs-15.1.1 lib/lhs/item.rb
lhs-15.1.0 lib/lhs/item.rb
lhs-15.0.2 lib/lhs/item.rb
lhs-15.0.1 lib/lhs/item.rb
lhs-15.0.0 lib/lhs/item.rb
lhs-14.6.5 lib/lhs/item.rb
lhs-14.6.4 lib/lhs/item.rb