Sha256: 932dcd1d5ab19e680466d2e00f3b995071c24e4253bd44d5f1eb538a30823124

Contents?: true

Size: 971 Bytes

Versions: 3

Compression:

Stored size: 971 Bytes

Contents

# An item is a concrete record.
# It can be part of another proxy like collection.
class LHS::Item < LHS::Proxy
  autoload :Becomes,
    'lhs/concerns/item/becomes'
  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 Becomes
  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.exclude?(name.to_s)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lhs-14.0.3 lib/lhs/item.rb
lhs-14.0.2 lib/lhs/item.rb
lhs-14.0.1 lib/lhs/item.rb