Sha256: b35cd014900d4125989bed8f4eaaaada4e487f61742c87a6a752b96a44ed8e30

Contents?: true

Size: 507 Bytes

Versions: 20

Compression:

Stored size: 507 Bytes

Contents

module Examples
  class ContextDelegation
    include JSON::SchemaBuilder
    attr_accessor :user
    delegate :admin?, to: :@user

    def example
      object additional_properties: false do
        string :name
        string :role if admin?
      end
    end

    def alternate_example
      object additional_properties: false do
        string :name
        string :role if user.admin?
      end
    end

    class User < OpenStruct
      def admin?
        role == :admin
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
json-schema_builder-0.8.2 spec/support/examples/context_delegation.rb
json-schema_builder-0.8.1 spec/support/examples/context_delegation.rb
json-schema_builder-0.8.0 spec/support/examples/context_delegation.rb
json-schema_builder-0.7.1 spec/support/examples/context_delegation.rb
json-schema_builder-0.7.0 spec/support/examples/context_delegation.rb
json-schema_builder-0.6.1 spec/support/examples/context_delegation.rb
json-schema_builder-0.6.0 spec/support/examples/context_delegation.rb
json-schema_builder-0.5.0 spec/support/examples/context_delegation.rb
json-schema_builder-0.4.0 spec/support/examples/context_delegation.rb
json-schema_builder-0.3.1 spec/support/examples/context_delegation.rb
json-schema_builder-0.3.0 spec/support/examples/context_delegation.rb
json-schema_builder-0.2.1 spec/support/examples/context_delegation.rb
json-schema_builder-0.2.0 spec/support/examples/context_delegation.rb
json-schema_builder-0.1.0 spec/support/examples/context_delegation.rb
json-schema_builder-0.0.9 spec/support/examples/context_delegation.rb
json-schema_builder-0.0.8 spec/support/examples/context_delegation.rb
json-schema_builder-0.0.7 spec/support/examples/context_delegation.rb
json-schema_builder-0.0.6 spec/support/examples/context_delegation.rb
json-schema_builder-0.0.5 spec/support/examples/context_delegation.rb
json-schema_builder-0.0.4 spec/support/examples/context_delegation.rb