Sha256: ba87f4e5387ef18475094e886cb6a8c3c775806933c69a5025f7eaee95b025bb

Contents?: true

Size: 878 Bytes

Versions: 1

Compression:

Stored size: 878 Bytes

Contents

# frozen_string_literal: true

module Archangel
  ##
  # Archangel custom Liquid resources
  #
  module Liquid
    ##
    # Liquid Drop for singular resources
    #
    class Drop < ::Liquid::Drop
      class << self
        attr_accessor :_associations
        attr_accessor :_attributes
      end

      def self.inherited(base)
        base._associations = {}
        base._attributes = []
      end

      ##
      # Build attributes
      #
      def self.attributes(*attrs)
        @_attributes.concat attrs

        attrs.each do |attr|
          next if method_defined?(attr)

          define_method(attr) do
            object.send(attr) if object.methods.include?(attr)
          end
        end
      end

      attr_reader :object

      ##
      # Initialize
      #
      def initialize(object, _options = {})
        @object = object
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
archangel-0.4.0 lib/archangel/liquid/drop.rb